Hi,
We have two companies setup in dynamics GP and there are crystal reports developed and they are calling from VBA. Now, the situation is, since there are two companies when we try to view the crystal report it is not retrieving the data from the logged in company, instead it is retrieving data in which crystal report is made. Given below is the code which is given in VBA for print button.
Private Sub PBPrint_BeforeUserChanged(KeepFocus As Boolean, CancelLogic As Boolean)
If VoucherNo.Value = "" Then
MsgBox "Please save the transaction first or Select an existing transaction"
Exit Sub
End If
Dim CP As CRAXDDRT.ConnectionProperties
Dim TBL
strRptSource = "BT"
Call modGeneral.GetConnection
Set CRReport = CRApp.OpenReport(MrptPath & "\Crystal Reports\rptCBT.rpt", 1)
For Each TBL In CRReport.Database.Tables
Set CP = TBL.ConnectionProperties
CP.Item("User ID") = MsqluserID
CP.Item("Password") = MsqlPwd
CP.Item("Data Source") = MDataSource
CP.Item("Initial Catalog") = UserInfoGet.IntercompanyID
Next TBL
'MsgBox CRReport.
CRReport.ParameterFields.Item(1).AddCurrentValue VoucherNo.Value
frmReportViewer.Show
End Sub
Please help.
Best Regards,
Renjan
*This post is locked for comments
I have the same question (0)