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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

msgbox will not display when data is populated via barcode reader

Status
Not open for further replies.

michellecole

Programmer
Feb 12, 2004
42
US
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
 
How are ya michellecole . . . .

When assigning a value to a TextBox thru [blue]VBA[/blue], the [blue]BeforeUpdate & AfterUpdate[/blue] events [purple]are not triggered![/purple] You'll find this stated in the help for these events.

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top