I have a Form, that I scan in a Bar Code. When I scan the Bar Code, the Form gets an 'Enter' and goes to the next record. I want it to Tab to the next field. I need to disable the Enter and enable a Tab.
How can I do that?
I have a Form, that I scan in a Bar Code. When I scan the Bar Code, the Form gets an 'Enter' and goes to the next record. I want it to Tab to the next field. I need to disable the Enter and enable a Tab.
How can I do that?
Removing the enter could be worked round. By making the form not allowing new records to be added?
Sendkeys event can be used to "simulate" the tab key be pressed.
Sent from my iPhone using Tapatalk
How about:
File>Options>Client Settings>Editing>Move after enter>Next Field
Each Form also has a Cycle Property on the Other Tab of the Property Sheet.
OK, I did Move After Enter, but now I need to get to the next record. Can I change the option in code?
You can move to the next record with code. When do you want to move? Is there an automatic place on your form to go to the next record? Maybe the last control on the form? You could also move to the next record with a button.
I found a way to get to a new record.
That works if I tab to the end of the form(Next Button), but fails if I Click the button before the end of the form.Code:Private Sub cmdCloseForm_Click() DoCmd.GoToRecord , , acNewRec Forms!Main.Visible = True End Sub
The Command Button wizard can make a Next Record button for you.
Here is the code for the Next Record button:
This almost works, but I need to move the cursor to the first field in the new record to get the scanner to the right place.Code:Private Sub Command0_Click() On Error GoTo Err_Command0_Click DoCmd.GoToRecord , , acNewRec Exit_Command0_Click: Exit Sub Err_Command0_Click: MsgBox Err.Description Resume Exit_Command0_Click End Sub
Is the "first field" the 1st object in the tab order? What is the name of the "First Field" Control on your form?
Yes, it's the first object in the tab order. The name is 'BarCodeID_PK'.
Try this:
Code:Private Sub Command0_Click() On Error GoTo Err_Command0_Click DoCmd.GoToRecord , , acNewRec Me.BarCodeID_PK.SetFocus Exit_Command0_Click: Exit Sub Err_Command0_Click: MsgBox Err.Description Resume Exit_Command0_Click End Sub
OK, that does it! Thanks.
Glad we could help. Enjoy the project.