Others

Use a USB Barcode Scanner in a Microsoft Access Form

Anum MushtaqAnum Mushtaq Nov 27, 2026 870 views

Question details

Set up a USB barcode scanner to enter values into an Access form and reset the form for the next scan.

How to Use a USB Barcode Scanner in a Microsoft Access Form
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.
Before you start

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.

Solution 1Recommended

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.

1
Test scanner input

Open Notepad or Word, click in a blank document, and scan a barcode. Confirm that the value appears correctly before testing in Access.

2
Configure the suffix

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.

3
Create test controls

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.

4
Add event procedures

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

5
Test the form

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.

6
Add processing after testing

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.

If Enter moves focus unexpectedly: Access keyboard settings or form behavior can affect where Enter sends focus. Check File > Options > Client Settings for Enter key behavior, and verify that each control receives its Key Up event before adding database-update logic.
Free Microsoft Office alternative

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.

Enter keyboard-emulating barcode scans into a selected spreadsheet cell.Open and edit Microsoft Excel XLS and XLSX files.Use a familiar spreadsheet interface for a smooth transition.Work with a free, lightweight office suite.
microsoft office alternative - wps office

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.