Setting Logon information for Custom report in Sage Accpac (300)

By | February 18, 2012

In Sage Accpac ERP, if you design a report using one Database say e.g. “SAMINC” and when you deploy it at clients end where database name is different say “SAMLTD”, then sometimes while executing the custom report through the custom report UI you get a error message “Logon failed” as shown on below screen.

This is because the report still tries to connect to the first database, which it has stored with itself.

To solve this error, you should pass the database connection details to the report at run time, using following code snippet

<Snip>
‘initialise crystal report application object
Set CrxApp = New CRAXDRT.Application
‘setting the report file name with complete path to open the report
Set CrxRep = CrxApp.OpenReport(report path variable)
‘Set your Database object to the Report object’s Database object
Set crxDatabase = CrxRep.Database
‘Set your DatabaseTables object to the Database object’s Tables object
Set crxDatabaseTables = crxDatabase.Tables
‘Loop through all tables in the report.
For Each crxDatabaseTable In crxDatabaseTables
‘delete the existing connection information linked to the report
crxDatabaseTable.ConnectionProperties.DeleteAll
‘set current log on information of the report
crxDatabaseTable.SetLogOnInfo l_str_DBNAME, l_str_DBNAME, l_str_UserID, l_str_Password
‘fill the reports connectionstring buffer with current logon information
crxDatabaseTable.ConnectBufferString = “DSN=” & l_str_DBNAME & “;;User ID=”   & l_str_UserID  & “;;Password=” & l_str_Password & “;;Database=” &   l_str_DBNAME & “;;UseDSNProperties=1”
Next  ‘ For Each crxDatabaseTable In crxDatabaseTables
‘Assign the report
frmReport.CRViewer1.ReportSource = CrxRep
‘Display the report
frmReport.CRViewer1.ViewReport
</Snip>

HAPPY CODING. For any quick help contact us on accpac@greytrix.com
About Us
Greytrix a globally recognized Premier Sage Gold Development Partner is a one stop solution provider for Sage ERP and Sage CRM needs. Being recognized and rewarded for multi-man years of experience, we bring complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third party add-on development and implementation expertise.

Greytrix offers unique GUMU™ integrated solutions of Sage 300 with Sage CRM, Salesforce.com and Magento eCommerce along with Sage 300 Migration from Sage 50 US, Sage 50 CA, Sage PRO, QuickBooks, Sage Business Vision and Sage Business Works. We also offer best-in-class Sage 300 customization and development services and integration service for applications such as POS | WMS | Payroll | Shipping System | Business Intelligence | eCommerce for Sage 300 ERP and in Sage 300c development services we offer services such as upgrades of older codes and screens to new web screens, newer integrations using sdata and web services  to Sage business partners, end users and Sage PSG worldwide. Greytrix offers over 20+ Sage 300 productivity enhancing utilities that we can help you with such as GreyMatrix, Document Attachment, Document Numbering, Auto-Bank Reconciliation, Purchase Approval System, Three way PO matching, Bill of Lading and VAT for Middle East.

For more details on Sage 300 and 300c Services, please contact us at accpac@greytrix.com. We will be glad to assist you.