There are two ways to do what you want to do depending on what type of
bar code scanner that you have. If you have a "keyboard wedge" type
scanner then you would need to encode commands into bar codes using a
syntax that you define so that commands are not confused with bar code
data. For example, you might enclose all commands in brackets and
leave actual bar code data un-bracketed.
As the last message in this thread recommended you would use code in
the AfterUpdate event for the textbox to examine the data in the
textbox and determine whether the data is a command or actual data. If
it is a command then use a Select Case statement to determine what
command to implement.
For example:
Private Sub Text0_AfterUpdate()
Dim MyText As String
MyText = Text0.Text
If Left(MyText, 1) = "{" And Right(MyText, 1) = "}" Then
' data just scanned was a command
Select Case UCase(MyText)
Case "{NEXTREC}"
' put code here to move to the next record
Case "{PREVREC}"
' put code here to move to the previous record
Case "{BEEP}"
MsgBox "beep"
End Select
Else
' the bar code that was scanned was not a command
' put code here to handle the actual bar code data
' that are not special commands
End If
End Sub
If you have a scanner that has an RS232 serial interface, you could do
things several other ways. With a RS232 scanner, you could use a
Software Wedge like WinWedge from TAL Technologies to pass all bar
code data directly to a Access subroutine using Dynamic Data Exchange
(DDE) and have the subroutine process the data directly using similar
logic in the above sample code.
You could also encode commands using ASCII control codes and then use
the character to keystroke translation table in the Software Wedge to
convert each specific ASCII control code received from the bar code
scanner to specific keystrokes that would implement the command by
issuing the correct keystrokes to the form. For example, suppose that
you encode an ASCII 1 in your bar code and you want that character to
represent a ALT - N keystroke on your form. You could translate the
ASCII 1 character in the Software Wedge to an ALT - N keystroke and
then when you scan the bar code while the form has the focus, the
Software Wedge would generate the ALT - N keystroke when you scan the
bar code containing the ASCII 1 character.
For more detailed information on WinWedge please visit:
http://www.taltech.com/products/winwedge.html