I have a form designed to create a purchase order. I saved it as a report in order for the user to print the same invoice when ready by using a command button provided on the form. I used the folowing code to link the form and the report.
Private Sub CommandPO_Click()
On Error GoTo Err_CommandPO_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "rptPO"
stLinkCriteria = "[POFormID]=" & Me![POFormID]
DoCmd.OpenReport stDocName, , , stLinkCriteria
Exit_CommandPO_Click:
Exit Sub
Err_CommandPO_Click:
MsgBox Err.Description
Resume Exit_CommandPO_Click
End Sub
I thought that this code will first open the purchase order saved as a report and then user will need to use menu or a command button on the report to print the matching invoice. But somehow, this invoice is printed straightaway without opening the report. Frankly, I couldn't ask for more but I would like to learn what is really triggering the printing process so that I can use the same technique in other contexts. Could someone shed light on why a command button on a form directly prints the report even though I have no such code in the report. Saving a form as report may have something to do this. I am using Access 97.
Cheers
Private Sub CommandPO_Click()
On Error GoTo Err_CommandPO_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "rptPO"
stLinkCriteria = "[POFormID]=" & Me![POFormID]
DoCmd.OpenReport stDocName, , , stLinkCriteria
Exit_CommandPO_Click:
Exit Sub
Err_CommandPO_Click:
MsgBox Err.Description
Resume Exit_CommandPO_Click
End Sub
I thought that this code will first open the purchase order saved as a report and then user will need to use menu or a command button on the report to print the matching invoice. But somehow, this invoice is printed straightaway without opening the report. Frankly, I couldn't ask for more but I would like to learn what is really triggering the printing process so that I can use the same technique in other contexts. Could someone shed light on why a command button on a form directly prints the report even though I have no such code in the report. Saving a form as report may have something to do this. I am using Access 97.
Cheers