I've configured our scanners to always send an {F9} before
sending the contents of the barcode, and an {Enter} afterwards. The
application has a AutoKeys macro (yes) that fires a routine that makes sure the
cursor is where it needs to be. I follow the contents with an {Enter}
keystroke, which effectively fires the AfterUpdate on the textbox.
The textbox is unbound, and it's AfterUpdate event does all
of the processing (validates the data, puts it where it needs it, moves the
focus, etc).
The AutoKeys macro {F9} fires this proc:
'***** code start *****'
Public Function
PrepScan()
'-- moves focus to scan textbox if necessary --
'-- called as part of scan instructions (via sendkeys) --
'-- moves focus to scan textbox if necessary --
'-- called as part of scan instructions (via sendkeys) --
If IsLoaded("frmScan") Then
With Forms!frmScan!txtBatchID
.SetFocus
.VALUE = Null
End With
End If
End Function
'***** code end *****'
The AfterUpdate event on the
txtBatchID control can (reasonably) expect the contents of the
barcode to be in that control. You can use the AfterUpdate event to do
whatever you need. If you're adding a record for every scan, I'd be
inclined to do the add programmatically as opposed to trying to move focus
around on a subform, which is error-prone and clumsy.
So, maybe something like
this:
'***** code
start *****'
Sub
txtBatchID_AfterUpdate()
If Not IsNull(Me.txtBatchID) Then
CurrentDb.Execute "INSERT INTO tblSomeTable (SomeField) VALUES (" &
Me.txtBatchID & ")", dbFailOnError +
dbSeeChanges
Me.SomeSubform.Form.Requery
End If
End
Sub
'***** code end
*****'
The barcode stuff I've
worked is some of my favorite programming - it's really amazing how much work
can be eliminated by utilizing barcodes &
scanners.
Tom Oakes
Personal PC Consultants, Inc.
[EMAIL PROTECTED]
503.230.0911 (O)
402.968.6946 (C)
734.264.0911 (F)
From: AccessDevelopers@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of brazilianbound
Sent: Friday, December 02, 2005 1:18 PM
To: AccessDevelopers@yahoogroups.com
Subject: [AccessDevelopers] Adding a new record on a event control
What i'm trying to do is when i scan my last barcode, i want it to go
and create a new record. So i'm trying to do this on the After_Update
event on the last control, but apparently i'm not getting it right.
Do anyone now what the proper syntax is?
Thanks as always
Clayton
Please zip all files prior to uploading to Files section.
SPONSORED LINKS
Microsoft access developer | Microsoft access help | Microsoft access database |
Microsoft access training | Microsoft access training course | Microsoft access programming |
YAHOO! GROUPS LINKS
- Visit your group "AccessDevelopers" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.