Submit Button:How can I assign a button to go to the next record and its first field?

nitinrao

Registered User.
Local time
Today, 14:02
Joined
Dec 17, 2009
Messages
26
I'm trying to set up a "Submit Button" which will allow you to go to the next record and the first field of the record upon clicking or pressing enter on it (in a form).
How can set up this command?

Thanks in advance!
 
Look at GoToRecord in VBA help.
 
Look at GoToRecord in VBA help.


All I could find was how to go to the next record...but I also want to go to the first field of the record
 
You could use;
Code:
Me.YourControlName.SetFocus
In the Form's On Current Event, to set the focus to any control you wish.
 
Also, the field that would normally receive focus first would be the first one in the tab order. You generally don't need code to go there first. You can certainly force the issue with SetFocus.
 
Also, the field that would normally receive focus first would be the first one in the tab order. You generally don't need code to go there first. You can certainly force the issue with SetFocus.

Where do I insert the code? I've tried inserting in "On Current Event" in sheet properties, but it gave me a error for not being able to recognize it. I also don't know where to put it in visual basic...i'm really new to this. Can someone guide me?
------------------------------------------------
UPDATE:
I've figured out that you add it between:
Private Sub Form_Current()


End Sub
If I want to add the field called "Last Name", what should my code look like? (I'm confused because of the space between the two words)

------------------------------------------------------------
Also, here is a pic of my form. I'm making Employee ID invisible in the form. So the first field (in new record) I want to go after I click on submit is "Last Name". I feel that data entry will be easier once I set this up because the user doesn't have to keep using the mouse to go to the new field when entering 1000+ keys.
 

Attachments

  • form.jpg
    form.jpg
    95.2 KB · Views: 140
Last edited:
.......
[/INDENT]If I want to add the field called "Last Name", what should my code look like? (I'm confused because of the space between the two words)

........

There's a neat little learning experience for you; Don't use spaces and other special characters in filed or object names. Stick with alpha numeric characters and the under score "_". Try names like FRM_FormName etc.

Given that you have used a space try enclosing the filed name in square brackets [Last Name]
 
There's a neat little learning experience for you; Don't use spaces and other special characters in filed or object names. Stick with alpha numeric characters and the under score "_". Try names like FRM_FormName etc.

Given that you have used a space try enclosing the filed name in square brackets [Last Name]

I've tried the code after taking out the space in the field name. But I still get the same error message after I put the code in. I've attached my code insertion and the error message. What is going wrong???

(the line above the code is the cursor)
 

Attachments

  • error.jpg
    error.jpg
    67.3 KB · Views: 141
  • newform.jpg
    newform.jpg
    97.2 KB · Views: 141
Have you just re-named the control on the form or have you gone back and renamed the field in the Table?

If you have simply renamed the field on the form, you will need to go back and re-name the field in the table.
 
Have you just re-named the control on the form or have you gone back and renamed the field in the Table?

If you have simply renamed the field on the form, you will need to go back and re-name the field in the table.

I've renamed the field in the table...it automatically updated the form as well.

Here is my database if it helps:

http://www.megaupload.com/?d=LCXNA1AS
 
OK ensure that you are referring to the correct control name. With the form in design view click on the control, now click on the Other tab of the properties box, the first field is Name, this will tell you the name that Access is using to refer to that control. If you have bound an unbound control to that Table field then the Name will be something like Text2 or something similar.
 
OK ensure that you are referring to the correct control name. With the form in design view click on the control, now click on the Other tab of the properties box, the first field is Name, this will tell you the name that Access is using to refer to that control. If you have bound an unbound control to that Table field then the Name will be something like Text2 or something similar.

The control name was "Last Name". I changed it to "LastName"...and reinserted the code. I still get the error message. Here is the updated database with the new control if you need to look at it:

http://www.megaupload.com/?d=ZA5JS5X1
 
You have got a Docmd command in Option Compare Database section of the VBA window :confused: I'm not sure what it's doing there but if you remove it the On Current event will work.
 
You have got a Docmd command in Option Compare Database section of the VBA window :confused: I'm not sure what it's doing there but if you remove it the On Current event will work.

Thanks so much John. The only problem now is that it isn't setting the focus to "Lastname" after I inserted the current event code......:( When I go to a new record, it doesn't automatically go to Lastname....
 
Works for me :confused:
It only works for me because I have my cursor in the LastName field (and the field is highlighted when you open it). If I click on another field (like email), and hit the "Submit" button or the new record icon, it goes to the next record but the same field (email)....

is this happening to you too?
 
No the cursor is set back at Last name.


hehe...i didn't enable macros...

thanks so much john...you helped me so much on this. I'll watch out for your threads so I can return the favor (when I get to the point that I know my stuff hehe)
 

Users who are viewing this thread

Back
Top Bottom