Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How cancel code when form closes or unloads

Status
Not open for further replies.

tmreic

Technical User
Joined
Feb 18, 2003
Messages
18
Location
US
I currently have the first listed set of code located behind one of my textboxes on a form. It is used to validate data entry on my form. The code works like it should when entering the data. But everytime i close or exit the form the code excutes and diplays the msgbox and inputbox. Is there a way to cancel this code just during the exiting of the form. I have tried other event but to no success. The second set of code is what i used stop the validation code from excuting as the form loads . I was tryed to do the same for the unload but to no succes.
Any Ideas?
Thank you,
Tim

Private Sub txtSerial_Exit(Cancel As Integer)
If testing = False Then
Exit Sub
End If

Dim VSid As String
VSid = Len(txtSerial.Text)
If VSid = 11 And testing = True Then
txtMillTube.SetFocus
Else
MsgBox "Invalid Virgo Serial Number" & vbCrLf & vbCrLf & " Please Rescan Correct Tag", vbOKCancel
Me!txtSerial = Null
txtSerial.Value = InputBox("Please Rescan Correct Tag")
Me!txtSerial.SetFocus
End If

End Sub

Option Compare Database
Option Explicit
Dim testing As Boolean

Private Sub Form_Close()
testing = False
End Sub

Private Sub Form_Load()
testing = True
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top