Command button - OnClick Property

dealwi8me

Registered User.
Local time
Tomorrow, 00:59
Joined
Jan 5, 2005
Messages
187
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.

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
 
Put this:

If IsNull(Me.CompanyName) then
........
 
thank you!
 

Users who are viewing this thread

Back
Top Bottom