barcode scanner combobox and which event to select

tubar

Registered User.
Local time
Today, 11:31
Joined
Jul 13, 2006
Messages
190
my barcode scanner works like a keyboard. i have a form that opens up with 1 combobox. i scan in a barcode. numbers appear in the combo box but no event happens...i have used the following code in after update, before update, on change, on eneter, and all the "key" options...is there something im missing in the code

Private Sub Combo0_KeyPress(KeyAscii As Integer)
On Error GoTo Err_Combo0_KeyPress

Dim stDocName As String
Dim stLinkCriteria As String



DoCmd.OpenForm "PURCHASE 2", , , ""
Forms("PURCHASE 2").Controls("CUSTOMERS").Value = Me.[Combo0]
DoCmd.Close acForm, Me.Name

Exit_Combo0_KeyPress:
Exit Sub

Err_Combo0_KeyPress:
MsgBox Err.Description
Resume Exit_Combo0_KeyPress


End Sub
 
Try putting another control on your form so the focus can move off of the ComboBox and see what happens.
 
WORKED LIKE A CHAMP!!! THANKS AGAIN



Private Sub Combo0_AfterUpdate()
On Error GoTo Err_Combo0_AfterUpdate

Dim stDocName As String
Dim stLinkCriteria As String



DoCmd.OpenForm "PURCHASE 2", , , ""
Forms("PURCHASE 2").Controls("CUSTOMERS").Value = Me.[Combo0]
Me.Form.SetFocus
DoCmd.Close acForm, Me.Name

Exit_Combo0_AfterUpdate:
Exit Sub

Err_Combo0_AfterUpdate:
MsgBox Err.Description
Resume Exit_Combo0_AfterUpdate


End Sub
 
Great! You should get in the habit of giving your controls a useful descriptive name. It helps maintaining the system years later.
 
Great! You should get in the habit of giving your controls a useful descriptive name. It helps maintaining the system years later.
+ 1

And avoid spaces in names - Tables, Fields, Querys, Forms, reports, objects ...
Underline is OK
 
thanks guys...great tips! bad habits!
 
I suggest you also avoid this:
Code:
Me.Form.SetFocus
DoCmd.Close acForm, Me.Name
If you want to go to a specific form you better put it's name.
You write this code to make sure the focus is going to specific form. me.form is the form that has the focus, not a specific one.

The same go for the DoCmd.Close
If you don't specify the form name it will close the form that has the focus. writing me.Name is the same as writing nothing at all.
 
I suggest you also avoid this:
Code:
Me.Form.SetFocus
DoCmd.Close acForm, Me.Name
If you want to go to a specific form you better put it's name.
You write this code to make sure the focus is going to specific form. me.form is the form that has the focus, not a specific one.

The same go for the DoCmd.Close
If you don't specify the form name it will close the form that has the focus. writing me.Name is the same as writing nothing at all.
I'm sorry to disagree but I believe the OP did exactly right. The SetFocus was to get the focus to leave the ComboBox so the events could occur and Me.Name returns the name of the current form.
 

Users who are viewing this thread

Back
Top Bottom