Hi Everyone, i have created a form and placed my CRLViewer control on it, and not a new form. Everytime a search button is pressed the report open. However, i only managing to open the report once in one session. When i click the search button 2nd time i get the parameters window and i get an error on the following line of code:
CRLViewer1.ReportSource = crlrep 'where crlrep is CRAXDRT.report
The bollow is my full code for the search button:
Private Sub cmdDepartmentSearch_Click()
Dim tbl As CRAXDRT.DatabaseTable
Dim sserver As String
Dim sDatabase As String
Dim SDBusername As String
Dim sDBPassword As String
Dim FromDate, ToDate As String
cd = (format(DTPicker4.value, "yyyyMMdd"))
cd1 = (format(DTPicker5.value, "yyyyMMdd"))
'Specify Report location and report itself
Set crlrep = crlApp.OpenReport("\\MCLERPSTORE\A4w\CustomReports\Procurement\Department Reports.rpt")
'specify connection string
crlrep.Database.LogOnServer "crdb_odbc.dll", "MCLERPSTORE32", "MCLDAT", "sa", "p@ssword123"
crlrep.Database.Tables.Item(1).ConnectionProperties.Item("password") = "p@ssword123" 'logon to tables
'clear any data to refresh the report
crlrep.DiscardSavedData
'specify parameters
crlrep.ParameterFields.GetItemByName("Fromdep").AddCurrentValue txtDept.Text
crlrep.ParameterFields.GetItemByName("ToDep").AddCurrentValue txtToDpt.Text
'crlrep.ParameterFields.GetItemByName("FromDate").AddCurrentValue cd
'crlrep.ParameterFields.GetItemByName("ToDate").AddCurrentValue cd1
'open the report
CRLViewer1.Refresh
CRLViewer1.ReportSource = crlrep
'crlrep.PrintOut False
CRLViewer1.ViewReport
CRLViewer1.Visible = True
End Sub
How can i fix this error