?
Solved

Set cursor back in text box after scanning in Access 2003 form

Posted on 2011-05-04
5
Medium Priority
?
390 Views
Last Modified: 2012-05-11
Hi all.

I have an Access 2003 form with a text box whose data is entered after the end user scans a barcode. When the end user scans the barcode that information is loaded onto a listbox and the text box is cleared so the end user can scan another barcode.

I want to be able to place the cursor back in the text box after scanning the barcode. I've tried using SetFocus but the end user still needs to manually drag the mouse to the textbox and click the textbox to be able to scan a new barcode.

How can I automatically set the cursor back in the text box? I have provided the code below. It is in the AfterUpdate event.

Thank you in advance!
Me.listNumbers.AddItem Me.txtNumbers

Me.txtNumbers.Value = ""

Me.txtNumbers.SetFocus

Open in new window

0
Comment
Question by:printmedia
  • 2
  • 2
5 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35692530
try setting the Tab Stop property of the listbox to NO
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 35692541
or you can leave the Tab Stop proerty of the listbox to yes, but add this code in the gotfocus event of the listbox

Private Sub listNumbers_GotFocus()
Me.txtNumbers.SetFocus

End Sub
0
 
LVL 61

Expert Comment

by:HainKurt
ID: 35692555
try adding RePaint

Me.listNumbers.AddItem Me.txtNumbers
Me.txtNumbers.Value = ""
Me.txtNumbers.RePaint
Me.txtNumbers.SetFocus
0
 
LVL 19

Expert Comment

by:Richard Daneke
ID: 35692796
Can SendKeys() be of any help here?
0
 
LVL 61

Expert Comment

by:HainKurt
ID: 35692885
do you have any more code (before and after the code you posted)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question