Hello Group
The code below works but if you hit cancel at any time it does not exit the sub, the form just fires up. Any suggestions on how to correct this.. It's probably simple for coders ..but I'm not one.
Thanks for any help on this one.
JZ
Testkitt2
The code below works but if you hit cancel at any time it does not exit the sub, the form just fires up. Any suggestions on how to correct this.. It's probably simple for coders ..but I'm not one.
Code:
Private Sub Location_AfterUpdate()
Dim stDocName As String, cancel As Boolean
Dim answer1 As Integer
Dim answer2 As Integer
Dim stDocNameNew As String
Dim stLinkCriteria As String
If Not IsNumeric(Me![Location]) And Not IsNumeric(Me![Location].OldValue) Then
Exit Sub
End If
If IsNumeric(Me![Location].OldValue) Then
MsgBox " Remove Old Position First !", vbOKCancel
stDocName = "FrmTirePosition"
stLinkCriteria = "[Fleet Number]=" & "'" & Me![Location].OldValue & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
ElseIf answer1 = vbCancel Then
cancel = True
Exit Sub
ElseIf IsNumeric(Me![Location]) Then
MsgBox "Add New Tire Position ? ", vbQuestion + vbOKCancel, "DB Admin"
stDocNameNew = "FrmTirePosition"
stLinkCriteria = "[Fleet Number]=" & "'" & Me![Location] & "'"
DoCmd.OpenForm stDocNameNew, , , stLinkCriteria
ElseIf answer2 = vbCancel Then
cancel = True
Exit Sub
End If
End Sub
Thanks for any help on this one.
JZ
Testkitt2