On Got Focus move to new record

asteadman

Registered User.
Local time
Today, 23:24
Joined
Jun 13, 2013
Messages
27
I have a subform that I use to scan in products using a barcode reader, when the item scans it moves to the quantity (Qty) field where I have this code:

Code:
Private Sub Qty_GotFocus()
    Qty.Value = 1
    DoCmd.GoToRecord , , acNewRec
    txtOrderNo.SetFocus
End Sub

I am simply trying to set the Qty value to 1 and move onto the next record ready to scan another product in. Any ideas?
 
what is happening now?
What doesn't work?
 
Should have said that the subform is based on a query, I guess that is why I have the error coming up stating that "you cannot go to the specified record".

Note to self: need to research moving to next record when form based on a query.
 
I can use the tab key to go to a new record so I tried vbTab however that didn't work either :(
 
Is txtOrderNo on the same form?

Try The After update event for QTY.

Dale
BTW. Your query is not the problem.
 
Is txtOrderNo on the same form?

Try The After update event for QTY.

Dale
BTW. Your query is not the problem.

Cheers, it works on the After Update event. Is there anything I can do on the set focus event so that after it sets the value to 1 it triggers the After Update event?
 
If I call the AfterUpdate event:
Call Qty_AfterUpdate

I get the same error as putting the code on GotFocus.

Is there a way I can trick access into thinking the user has selected a value for the Qty combobox?
 
me.Qty = 1 works.
Impossible to control, but it works.

DALE

BTW. AfterUpdate will fire only after a keyboard entry.
 
This works.
Every time you hit the tab key it makes a new record and 1 is stored in the Qty field.


Code:
Private Sub numTest_GotFocus()
Me.numTest = 1
Me.Testtext.SetFocus
DoCmd.GoToRecord , , acNewRec
End Sub

Dale
 
Cheers guys.

The issue with the above code Dale is that there is the odd occasion where the Qty will need to be more than 1.

I have used your suggestions and will instruct the user that they have to press enter to fire the AfterUpdate event to go to the next product.

This will have to do for now, I need to move on haha.

Cheers for the help, much appreciated.
 

Users who are viewing this thread

Back
Top Bottom