Hi,
I'm currently designing an inventory system for my workplace using a barcode scanner (software keyboard wedge type).
At present I have it use the prefix CTRL + B
On my form (access 2007) I have the keypress event monitor for the acsii code for CTRL + B (Ascii 2) as this appears to do nothing to the form.
When Ascii code 2 is detected, opens an input box for the barcode.
Then when barcode is entered and carriage return is hit (Barcode suffix) a search is triggered:
Now where I need help, is working out how to trigger an event if nothing is found. In this case I plan to have it open a new record, and drop the contents of my string into the barcode box.
My current sub below:
I'm currently designing an inventory system for my workplace using a barcode scanner (software keyboard wedge type).
At present I have it use the prefix CTRL + B
On my form (access 2007) I have the keypress event monitor for the acsii code for CTRL + B (Ascii 2) as this appears to do nothing to the form.
When Ascii code 2 is detected, opens an input box for the barcode.
Then when barcode is entered and carriage return is hit (Barcode suffix) a search is triggered:
Code:
DoCmd.FindRecord strName, acAnywhere, False, acSearchAll, False, acAll, True
Now where I need help, is working out how to trigger an event if nothing is found. In this case I plan to have it open a new record, and drop the contents of my string into the barcode box.
Code:
'DoCmd.GoToRecord , , acNewRec
'barcode.Value = strName
My current sub below:
Code:
Private Sub Form_KeyPress(KeyAscii As Integer)
Dim strName As String 'Barcode string
If KeyAscii = 2 Then
Beep
barcode.SetFocus
'Open an input box for barcode
strName = InputBox(Prompt:="PLEASE ENTER BARCODE:", _
Title:="ENTER BARCODE!", Default:="9315626027678")
If strName = "ALPACA" Or _
strName = vbNullString Then
Exit Sub
Else
'search for barcode
DoCmd.FindRecord strName, acAnywhere, False, acSearchAll, False, acAll, True
'<<<< Start Code to be run if nothing found
'DoCmd.GoToRecord , , acNewRec
'barcode.Value = strName
'<<<< End Code to be run if nothing found
End If
stock.SetFocus
'<<< Redundant function
'Command17_Click
'<<< Redundant function
End If
End Sub