michellecole
Programmer
I have a form, frmBarcodeScan, that allows the user to populate a text box, barcode, manually or via a barcode reader. (The barcode is always 8 digits). Included in the AfterUpdate event for the barcode textbox is a command to set the focus to another text box, txtRoute, on the same form. The OnGotFocus event for txtRoute looks up the applicable route in a table and if one is not found, it populates "Unk" in txtRoute and displays a msgbox . Here's my problem, if the initial barcode is manually entered, the message box displays. However, if the barcode is scanned via barcode reader - the message box will not display. Does anyone know why the message box won't display? My goal is to automate the form as much as possible so that the user only has to scan and does not have to “Click” the keyboard or use the mouse.
Thank you in advance for your advice!
Michelle
Private Sub Barcode_AfterUpdate()
Me![Source] = Left(([Barcode Info]), 4)
Me![BagNumber] = Right(([Barcode Info]), 4)
Form.Refresh
strSetFocus = "txtRoute" 'flag used in a conditional statement when txtRoute receives focus
DoCmd.GoToControl "txtRoute"
txtRoute.SetFocus
End Sub
Private Sub txtRoute_GotFocus()
On Error GoTo txtRoute_Err
If strSetFocus = "txtRoute" Then 'just scanned a bag and need to lookup route....
Dim sDate As String
sDate = Format(Date, "w", "1")
Select Case sDate
Case "1", "2", "3", "4", "5", "6"
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE Schedule LEFT JOIN Input ON Schedule.[Master Source] = Input.Source SET Input.Route = [Schedule].[Route]" & _
"WHERE (((Schedule.ScheduleDay)= '1') AND ((Schedule.ArriveStart)<=Time()) AND ((Schedule.ArriveEnd)>=Time()));"
Case Else 'Saturday
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE Schedule LEFT JOIN Input ON Schedule.[Master Source] = Input.Source SET Input.Route = [Schedule].[Route]" & _
"WHERE (((Schedule.ScheduleDay)= '2') AND ((Schedule.ArriveStart)<=Time()) AND ((Schedule.ArriveEnd)>=Time()));"
End Select
If Len([txtRoute]) < 4 Then
DoCmd.SetWarnings False
[txtRoute] = "Unk"
txtRoute.SetFocus
DoCmd.SetWarnings True
Issue-> MsgBox ("Please enter Route"), vbOKOnly, "Please enter Route...."
Exit Sub
Else
:
:
:
Thank you,
Michelle
Thank you in advance for your advice!
Michelle
Private Sub Barcode_AfterUpdate()
Me![Source] = Left(([Barcode Info]), 4)
Me![BagNumber] = Right(([Barcode Info]), 4)
Form.Refresh
strSetFocus = "txtRoute" 'flag used in a conditional statement when txtRoute receives focus
DoCmd.GoToControl "txtRoute"
txtRoute.SetFocus
End Sub
Private Sub txtRoute_GotFocus()
On Error GoTo txtRoute_Err
If strSetFocus = "txtRoute" Then 'just scanned a bag and need to lookup route....
Dim sDate As String
sDate = Format(Date, "w", "1")
Select Case sDate
Case "1", "2", "3", "4", "5", "6"
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE Schedule LEFT JOIN Input ON Schedule.[Master Source] = Input.Source SET Input.Route = [Schedule].[Route]" & _
"WHERE (((Schedule.ScheduleDay)= '1') AND ((Schedule.ArriveStart)<=Time()) AND ((Schedule.ArriveEnd)>=Time()));"
Case Else 'Saturday
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE Schedule LEFT JOIN Input ON Schedule.[Master Source] = Input.Source SET Input.Route = [Schedule].[Route]" & _
"WHERE (((Schedule.ScheduleDay)= '2') AND ((Schedule.ArriveStart)<=Time()) AND ((Schedule.ArriveEnd)>=Time()));"
End Select
If Len([txtRoute]) < 4 Then
DoCmd.SetWarnings False
[txtRoute] = "Unk"
txtRoute.SetFocus
DoCmd.SetWarnings True
Issue-> MsgBox ("Please enter Route"), vbOKOnly, "Please enter Route...."
Exit Sub
Else
:
:
:
Thank you,
Michelle