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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

simplified AfterUpdate? 1
Run-Time Error 2501 The OpenForm action was cancelled 1
no focus 3
SQL Result to a variable 1
<= 0 11
Password 9
OnExit driving me crazy 3
Bit of help needed on Validation Function ElseIf 7

Back
Top