I have a data varification process that is working great but, when a "box end" is entered as a file name the process of clearing the default values and setting the focus back to the tracking number (BoxNumber) is erroring out.
I ran into something simular but in this cace I don't want to cancel the entry, I just want to accept it and clear the values and set the focus to [me.boxnumber] so that the input form is ready for the next box to be processest for shipment.
THANKS!!
Thanks
John Fuhrman
I ran into something simular but in this cace I don't want to cancel the entry, I just want to accept it and clear the values and set the focus to [me.boxnumber] so that the input form is ready for the next box to be processest for shipment.
THANKS!!
Code:
Private Sub FileNumber_BeforeUpdate(Cancel As Integer)
Dim TrackingDate As Date
Dim dl As String
dl = vbNewLine & vbNewLine
Dim strResult As String
Me.TrackingDate = Now
Select Case Len(Me.FileNumber)
Case Is < 7
Cancel = True
MsgBox Me.FileNumber & " is not a Valid File Number" & dl & _
"Please Correct the File Number ...", _
vbExclamation + vbOKOnly, _
"ERROR!"
Exit Sub
Case 8 To 13
If IsAlpha(left(Me.FileNumber, 3)) = True Then
Select Case UCase(left(Me.FileNumber, 3))
Case "SRC", "LIN", "WAC", "EAC", "MSC"
'Continue
Case Else
Cancel = True
strResult = MsgBox(Me.FileNumber & " is not a Valid File Number" & dl & _
"Please Correct the File Number ...", _
vbExclamation + vbOKOnly, _
"ERROR!")
Select Case strResult
Case vbOK, vbRetry, vbYes, vbNo
Exit Sub
Case vbCancel, vbAbort, vbIgnore
Exit Sub
Case Else
Exit Sub
End Select
End Select
ElseIf IsAlpha(left(Me.FileNumber, 1)) = True Then
Select Case UCase(left(Me.FileNumber, 1))
Case "A", "T", "S", "W"
'Continue
Case Else
Cancel = True
strResult = MsgBox(Me.FileNumber & " is not a Valid File Number" & dl & _
"Please Correct the File Number ...", _
vbExclamation + vbOKOnly, _
"ERROR!")
Select Case strResult
Case vbOK, vbRetry, vbYes, vbNo
Exit Sub
Case vbCancel, vbAbort, vbIgnore
Exit Sub
Case Else
Exit Sub
End Select
End Select
[red] ElseIf UCase(Me.FileNumber) = UCase(".box.end.") Then
'End of box processing[/red]
Else
Cancel = True
strResult = MsgBox(Me.FileNumber & " is not a Valid File Number" & dl & _
"Please Correct the File Number ...", _
vbExclamation + vbOKOnly, _
"ERROR!")
Select Case strResult
Case vbOK, vbRetry, vbYes, vbNo
Exit Sub
Case vbCancel, vbAbort, vbIgnore
Exit Sub
Case Else
Exit Sub
End Select
End If
Case Is > 13
Cancel = True
MsgBox Me.FileNumber & " is not a Valid File Number" & dl & _
"Please Correct the File Number ...", _
vbExclamation + vbOKOnly, _
"ERROR!"
Exit Sub
End Select
[red]
If UCase(Me.FileNumber) = UCase(".box.end.") Then
Me.BoxNumber.DefaultValue = ""
Me.FileNumber.DefaultValue = ""
DoCmd.GoToRecord , , acNewRec
Me.BoxNumber.SetFocus
' Me.FileNumber.Value = ""
' Me.BoxNumber.Value = ""
' Me.TrackingDate.Value = ""
Exit Sub
Else
Me.BoxNumber.DefaultValue = """" & Me.BoxNumber & """"
End If
[/red]
endit:
Exit Sub
err_Handler:
Select Case Err
Case 2501
'Do Nothing
Case Else
MsgBox _
"An unexpected error has been detected" & Chr(13) & _
"Error Number: " & Err.Number & " , " & Err.Description & Chr(13) & _
vbCrLf & "Please note the above details before contacting support"
End Select
Resume endit
End Sub
Thanks
John Fuhrman