Need a little help as i am a novice.
Using 1 form to select an option, depending on that option a string variable is populated with a path. (this bit works fine) as follows.
I have declared as....
public reportpath as string
Button click code;
Private Sub cmdrunrep_Click()
'On Error GoTo errortrap
If Frame15.Value = 1 Then
reportpath = "S:\reports\ITPR_Summary_PLC"
Else
If Frame15.Value = 2 Then
reportpath = "S:\reports\ITPR Lookup PLC"
End If
End If
Text26.SetFocus
Text26.Text = reportpath
'run the report viewer macro
DoCmd.RunMacro "runrep"
The runrep macro loads a form with crystal reports control on it.
and the load form code is ;
Private Sub form_Load()
On Error GoTo errortrap
Dim crReport As CRAXDRT.Report
Dim crApplication As New CRAXDRT.Application
Set crReport = crApplication.OpenReport(reportpath)
Text3.SetFocus
Text3.Text = reportpath
crv.ReportSource = crReport
crv.ViewReport
errortrap:
MsgBox Err.Description
Exit Sub
End Sub
Using the public string variable named reportpath at this point is empty and loses the actual path. As you can see i have added some temporary text boxes to see what the variable contains. It is empty on form load.
Please help the rest works fine. I feel i have done all the hard work but now i want it to run 1 of several reports i have missed something simple.
PS. just hard coding the report path into the form load event works fine and runs the Crystal ActiveX no problem. Just need to be able to pass the changing report path over to the load event from the button click event.
Regards
Simon
Using 1 form to select an option, depending on that option a string variable is populated with a path. (this bit works fine) as follows.
I have declared as....
public reportpath as string
Button click code;
Private Sub cmdrunrep_Click()
'On Error GoTo errortrap
If Frame15.Value = 1 Then
reportpath = "S:\reports\ITPR_Summary_PLC"
Else
If Frame15.Value = 2 Then
reportpath = "S:\reports\ITPR Lookup PLC"
End If
End If
Text26.SetFocus
Text26.Text = reportpath
'run the report viewer macro
DoCmd.RunMacro "runrep"
The runrep macro loads a form with crystal reports control on it.
and the load form code is ;
Private Sub form_Load()
On Error GoTo errortrap
Dim crReport As CRAXDRT.Report
Dim crApplication As New CRAXDRT.Application
Set crReport = crApplication.OpenReport(reportpath)
Text3.SetFocus
Text3.Text = reportpath
crv.ReportSource = crReport
crv.ViewReport
errortrap:
MsgBox Err.Description
Exit Sub
End Sub
Using the public string variable named reportpath at this point is empty and loses the actual path. As you can see i have added some temporary text boxes to see what the variable contains. It is empty on form load.
Please help the rest works fine. I feel i have done all the hard work but now i want it to run 1 of several reports i have missed something simple.
PS. just hard coding the report path into the form load event works fine and runs the Crystal ActiveX no problem. Just need to be able to pass the changing report path over to the load event from the button click event.
Regards
Simon
Last edited: