Why my Exit event fires twice?

GKIL67

Registered User.
Local time
Today, 04:12
Joined
Apr 28, 2011
Messages
24
Hello all,

The following modules are from a Continuous Forms view form.
I want to check the TSTATUS and if it is 'S02' to provide the option of selecting a Vendor from the TSinfo.
Then I want to check again for a null value, allowing however the option of a null value, if the user exits TSinfo (maybe accidentally) without selecting a Vendor.

For some strange reason, the Exit event fires twice (the strmsg pops up twice) if the user (lets say by mistake) clicks on another record.

I've tried different ways, including the Before Update, but this is what suits me most.
Can anybody help me make it to work and maybe explain why this happens?

Your any assistance is greatly appreciated!
=================================
Private Sub TSinfo_Exit(Cancel As Integer)
Dim strmsg As String
strmsg = "You forgot to select a Vendor!" & vbCrLf & "Will you be placing an order?"

If IsNull(Me.TSinfo) And MsgBox(strmsg, vbCritical + vbYesNo, "Attention!!!") = vbYes Then
Cancel = True
Else
Me.TSTATUS.SetFocus
Me.TSinfo.Enabled = False
End If
End Sub


Private Sub TSTATUS_AfterUpdate()
If Me.TSTATUS = "S02" Then
AskUser = MsgBox("If you place an order you have to provide a Vendor!" & vbCrLf & _
"Will you place an order?", vbCritical + vbYesNo, "Attention!!!")
End If
If AskUser = vbYes Then
Me.TSinfo.Enabled = True
Me.TSinfo.SetFocus
Else
Me.TSTATUS.SetFocus
Me.TSinfo.Enabled = False
End If
End Sub
 
I had to come back to this and close it... I ended up using the Before Update event. It is the most suitable for this kind of operations.
 

Users who are viewing this thread

Back
Top Bottom