Enter barcode automatically in textbox

aman

Registered User.
Local time
Yesterday, 21:45
Joined
Oct 16, 2008
Messages
1,251
Hi Guys

I am designing a project in which in the input form,when the person scans the barcode and it comes up in the textbox.I have written the following code on save button:

Code:
Private Sub Command19_Click()
Dim sSQL As String
sSQL = "INSERT INTO inputtable ([date],location,department,BleepedBarcode,Signature) VALUES (#" & Format(Me.Text4.Value, "mm-dd-yy") & "#, '" & Me.Combo12.Value & "','" & Me.Combo15.Value & "', '" & Me.Text17.Value & "','No')"
DoCmd.SetWarnings False
DoCmd.RunSQL sSQL
     
    Text17.Value = ""
    Text17.SetFocus

It works fine and saving the values in the table.
But my requirement is when the barcode is scanned then it appears in the textbox and without pressing SAVE button ,the above code should run..Which event can i use to solve this problem.So that I can enter multiple barcodes in the textbox one by one without pressing save button and automatically they get saved in the database.
Regards
Aman
 
If the barcodes are all the same length then you can use the autotab property on the textbox but you will need to setup an input mask so that the text box knows when the last character has been entered.

David
 
Hi Dcrake

Thanks for your reply.Even i don't know whether the barcodes are of same length or not. Suppose they are same always then how can i set the input mask of that control.
And if they are not same then how can I get the required result.

Thanks
Aman
 
Essentially all you are are attempting to do is to fire the code when the last character has been entered. If you open up wordpad and scan a barcode it will effectively key in the response by way of a number. Try this with a few bar codes, they should all be the same length.

Next in your textbox set the input mask to match the same number of digits as the barcode.
 
Hi Dcrake

The number of characters are 13 always for barcode so I have set the auto tab property "Yes" . But I have no idea how can I set the input mask property of that control so that when 13th character is entered then control goes to next control acc. to tab order.

Thanks
AMan
 
Go into the design of the form and click on the control textbox and go to properties.

Click on the input mask event and type in

0000000000000;;_

Now try and scan a barcode into the control in form view.
 
Hi Drake

Thanks for your reply.. I used AAAAA.. in the input mask as the barcode consists of numbers as well as alphabets too..

And also I have set the auto tab property true so that cursor passes to the next control automatically. Its all working fine.
But now my requirement is when barcode is scanned in a textbox then it saves the record in the table and control remains in that textbox only.

I don't want to pass the cursor to the next control but the cursor should remain in the same textbox.

Regards
AMan
 
If you can make all you other controls

Enabled = False
Locked = True

Or

Using the multi selection for form controls set the TabStop property to False

Or

On the GoFocus or then next control in the tab order
enter Me.PreviousControl.SetFocus


However if none of this is not possible then get back and we will try other things
 
Hi Drake

Thanks very much for your help..My problem is solved.

Cheers
AMan
 
Hi Dcrake

On the got focus event of next control,I wrote:
me.textbox.setfocus

and on the lost focus event of barcode textbox I had written the save record statement.

Thanks again for your help.

Regards
AMan
 

Users who are viewing this thread

Back
Top Bottom