Or statement.

  • Thread starter Thread starter cmichaud
  • Start date Start date
C

cmichaud

I am trying to add a statement to this existing one. It is attached to
the onclick event of a button.


Private Sub Command7_Click()
DoCmd.OpenReport "rptClubRegistry", acViewPreview, , "[ClubID] = " &
Me.ClubID
End Sub


I want to make it so that if ClubID (on the form, a combobox) is left
null it will return the entire report.

Does it go like this

DoCmd.OpenReport "rptClubRegistry", acViewPreview, , "[ClubID] = " &
Me.ClubID
Or If Me.ClubID is Null Then
DoCmd.OpenReport "rptClubRegistry",,acViewPreview
End If
End Sub

Kinda new here. Ok very new,
 
Private Sub Command7_Click()

If IsNull(Me.ClubID) Then
DoCmd.OpenReport "rptClubRegistry",,acViewPreview
Else
DoCmd.OpenReport "rptClubRegistry", acViewPreview, , _
"[ClubID] = " & Me.ClubID
End If

End Sub
 
Humm...that sent it straight to the printer for some reason. It lets
me preview it when i make a selection but if i leave it blank it send
is right to the printer......????
 
Likely because you have two commas before the acViewPreview command, which
means it's being treated as a filter, rather than a View command.

Sorry: I just copied your code, I didn't proof read it! <g>
 
Back
Top