Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want to go to first field in record when New Record button is clicked. 1

Status
Not open for further replies.

iowabuckmaster

Technical User
May 21, 2003
36
US
Form is based on a table.
After adding or editing a record in the form. If I press the New Record button, Access takes me to a New record BUT the curser is in whatever field I happened to be in on the previous record, when I clicked on the New Record button. I want it to go to the first field of the New Record which is Invoice Number. Do I need an Event Procedure (code) tied to one of the form properties? This seems like a fairly standard procedure, so forgive me if I am missing something obvious. Thanks for any help.
 
In the code of the button that takes you to a new record (on click) try adding the following

DoCmd.GoToControl "TextBoxName"

You need to set the focus to the Invoice Filed.

HTH



An investment in knowledge always pays the best dividends.
by Benjamin Franklin
 
This will insert a new record and move the cursor to what ever field you want.

DoCmd.GoToRecord , , acNewRec
Me![name of your field].SetFocus
 
What Code? I am just clicking on the Access's standard New Record Button. I should have said this better. Sorry Try this question now. Can I go to the First field of a New Record by Using the Access's New Record Buttons. Or do I have to create my own New Record Button to accomplish my goal? Thanks
 
set the [tab stop] property for that text box to 0

This way when you insert a new record the cursor will automatically go to that box.
 
You will have to create your own button that when clicked will take you to a new record. As you can see, there is usually more then one way to accompolish something. Go into the design view of the form and add the button. Either use the wizzard or the following code in the On Click Event of the button.

DoCmd.GoToRecord , , acNewRec
DoCmd.GoToControl "TextBoxName"

or

DoCmd.GoToRecord , , acNewRec
Me![name of your field].SetFocus

What you are doing is telling Access to go to a new record and then setting the focus to the spcific filed you want. Remember, anytime you go to a new record or close the current record will be saved as is, unless you use some code to stop the saving.

An investment in knowledge always pays the best dividends.
by Benjamin Franklin
 
Tab Stop can only be set to Yes or No, and Tab Index is 0.

SO it sounds like I have to create my own New Record Button. That's OK. Not a big deal, the users are Access literate so I wasn't going to have a bunch of buttons for finding, saving, sorting and stuff. But I'll need a New Record button. Thanks for the help.

Just curious, when you click on Access's New Record Button, does any Form events take place like, On Load, or After Update. Thought maybe I could put the code in an event procedure that takes place. No?
 
mph1
I don't thing he/she wants to use code. I believe they just want the cursor to move to the Invoice Number field went a new record is inserted.

This is my take on it from the original post.
 
Hi!

I think you could try a setfocus, as mph1 describes, in the forms on current event.

HTH Roy-Vidar
 
Oups, should have said as described above, did not intentionally forget you, nice95gle, sorry.

Roy-Vidar
 
the only code that is use is this:

Code:
DoCmd.GoToRecord , , acNewRec

And some error trapping code but what could go wrong with adding a record?

If I take a peek in your Windows, to fix a problem, does that make me a "Peeping Tom"? Hmmmmmmmmmmv [pc1][shocked]
 
You could put the setfocus in the On_click of the button and it will work just fine.

If I take a peek in your Windows, to fix a problem, does that make me a "Peeping Tom"? Hmmmmmmmmmmv [pc1][shocked]
 
That's it. It works now using this.

For the Form. On Current. Event Procedure is this.

Private Sub Form_Current()
Me![Invoice Number].SetFocus
End Sub

Always goes to the first field(Invoice Number) no matter where I left off. Doesn't matter if it is the first record last record or going to a new record from another record. That is what they want.

Thanks all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top