web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

cystal report

(0) ShareShare
ReportReport
Posted on by 185

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)
  • Shankar M Profile Picture
    55 on at

    Hi Renjan,

    I Hope the "Save Data with Report" option is marked in that report.So that whenever you run the report the same old values is displayed. Can you open that report and check it in the design mode, whether the  default setting "Save Data with Report." is marked ? If so then unmark that option and save the report and check.

    Regards,

    shan

  • Suggested answer
    Nancy Chavez Profile Picture
    195 on at

    Hi Renjan,

    It depends on how you want to handle your reports. We have the same function, but we have a different report for each company, so, in the code we call the report path from a table depending on what company is selected.

  • Suggested answer
    Richard Whaley Profile Picture
    25,195 on at

    No, the saved data with report flag is not the issue.  Crystal accesses data via an ODBC and when the Crystal report runs, it uses the established specs in the ODBC to determine which db to open.

  • Mickie Stamm Profile Picture
    20 on at

    Hi Renjan,

    We have used this successfully in the past:

    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

     Dim location as string = TBL.Location  

     TBL.Location = location    'we have seen that sometimes it helps to reassign the same value

    Next TBL

    Hope that helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
mtabor Profile Picture

mtabor 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans