vbOk

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

cmichaud

I am struggling with this code. I am trying to get it so if the field
is no it will tell the user, they will hit ok...then go and enter a
value

If IsNull(Me.YearID) Then
MsgBox("You must enter a year.", vbOKOnly) = vbOK
Else
DoCmd.OpenReport "rptClubAA", acViewPreview, , "[YearID] = " &
Me.YearID
End If
 
If IsNull(Me.YearID) Then
MsgBox "You must enter a year."
me.YearID.setfocus
Else
DoCmd.OpenReport "rptClubAA", acViewPreview, , "[YearID] = " &
Me.YearID
End If
 
I'm not sure what is the problem, but try this

If IsNull(Me.YearID) or Me.YearID= "" Then
MsgBox("You must enter a year."
Me.YearID.SetFocus
Else
DoCmd.OpenReport "rptClubAA", acViewPreview, , "[YearID] = " &
Me.YearID
End If
 
MsgBox functions in two ways: as a function that returns a value
corresponding to the button that was clicked, or as a sub that just displays
the message box and waits until a button is clicked. If you don't care what
button was clicked, use the Sub version. (the difference is whether or not
you enclose the arguments in parentheses)
 
Back
Top