MsgBox Twice (1 Viewer)

rgwfly

Registered User.
Local time
Today, 01:43
Joined
Jun 7, 2016
Messages
49
I looked online and tried several different options.

I am looking to have a message pop up when an entry is not completed.
The following code seems to work well but I keep getting the message box twice. I understand it seems to be firing twice but not sure what part of the code is causing this.

#Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.cboProject) Then
MsgBox "The Project Must be entered" & vbCrLf & _
"Please select from the drop down box.", _
vbCritical, _
"Canceling Update"
DoCmd.CancelEvent
Me.cboProject.SetFocus
End If
End With

End Sub#
 

JHB

Have been here a while
Local time
Today, 10:43
Joined
Jun 17, 2012
Messages
7,732
I don't know if that would help, but use the event's Cancel instead of "DoCmd.CancelEvent"
Code:
...
"Please select from the drop down box.", _
vbCritical, _
"Canceling Update"
[COLOR=Red][B] Cancel=True[/B][/COLOR]
Me.cboProject.SetFocus
...
 

moke123

AWF VIP
Local time
Today, 04:43
Joined
Jan 11, 2013
Messages
3,920
you also appear to have a stray "End With"
 

Users who are viewing this thread

Top Bottom