Use a USB Barcode Scanner in a Microsoft Access Form
Question details
Set up a USB barcode scanner to enter values into an Access form and reset the form for the next scan.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A user scans a barcode, enters a quantity, and wants the form ready for the next item.
- Observed behavior
- The previous barcode can remain in the field, causing the next scan to be appended, and the quantity needs to return to 1.
Connect the scanner and check its manual for keyboard-emulation and suffix settings. Use an unbound test form so scans do not immediately change database records.
Test the scanner and reset Access form fields with VBA
Use this workflow to verify scanner input, move from the barcode to the quantity field, and reset both fields after a test scan.
Open Notepad or Word, click in a blank document, and scan a barcode. Confirm that the value appears correctly before testing in Access.
Use the scanner's configuration guide to enable an Enter suffix after each scan. If input does not appear in Notepad or Word, resolve the scanner connection or configuration first.
In Access, open the form in Design View and add two unbound text boxes. In each control's Property Sheet, set its Name to BarcodeInput or QuantityInput, respectively, and set QuantityInput's Default Value to 1.
Select each text box, open Property Sheet > Event, set On Key Up to [Event Procedure], and click the build button to open the VBA editor. Add these procedures to the form's module: Private Sub BarcodeInput_KeyUp(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn And Len(Nz(Me.BarcodeInput.Value, "")) > 0 Then Me.QuantityInput.SetFocus End If End Sub Private Sub QuantityInput_KeyUp(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then MsgBox "Test scan: " & Nz(Me.BarcodeInput.Value, "") & ", quantity: " & Nz(Me.QuantityInput.Value, 1) Me.BarcodeInput.Value = Null Me.QuantityInput.Value = 1 Me.BarcodeInput.SetFocus End If End Sub
Open the form in Form View, click BarcodeInput, and scan. Check that focus moves to QuantityInput, enter a quantity, and press Enter. Dismiss the test message and confirm that the barcode is cleared, the quantity is 1, and focus returns to BarcodeInput.
In the QuantityInput_KeyUp procedure, replace the MsgBox line with your validated scan-processing or database-update code. Reset the controls only after processing succeeds.
Use WPS Office for Scanner-Friendly Spreadsheet Workflows
WPS Office is a free, lightweight Office alternative with a familiar interface and compatibility with common Microsoft Office formats, making it easy to move spreadsheet workflows. It does not replace Access or fix Access form events.

Frequently Asked Questions
Why does my scanner work in Notepad but not in my Access form?
Click the barcode text box in Form View before scanning. If the scan appears in the wrong control, check the form's focus and tab order; if the Enter suffix causes unexpected navigation, check Access keyboard settings.
How do I stop the next barcode from being appended to the previous one?
After successfully processing a scan, set the unbound barcode control to Null, for example, Me.BarcodeInput.Value = Null, and return focus to it with Me.BarcodeInput.SetFocus.
How do I reset the quantity to 1 after each scan?
Set the quantity control's Default Value to 1 for the initial entry, and use Me.QuantityInput.Value = 1 after each successful scan to reset it for the next item.
Does the sample VBA update my Access tables?
No. The sample displays a test message and resets the controls. Replace the MsgBox line with your own validated processing code only after the scanner and focus behavior work as expected.




