I have a button in a form which i want to print Report1 if the CompanyName is null or Report2 if the CompanyName is not null.
I wrote the following code but when i click on the button i get the message "Object Required."
Any suggestions?
Thank you in advance.
I wrote the following code but when i click on the button i get the message "Object Required."
Any suggestions?
Thank you in advance.
Code:
Private Sub Command62_Click()
On Error GoTo Err_Command62_Click
Dim stDocName As String
If Me.CompanyName Is Null Then
stDocName = "Report1"
DoCmd.OpenReport stDocName, acNormal
Else
stDocName = "Report2"
DoCmd.OpenReport stDocName, acNormal
End If
Exit_Command62_Click:
Exit Sub
Err_Command62_Click:
MsgBox Err.Description
Resume Exit_Command62_Click
End Sub