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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button problem 1

Status
Not open for further replies.

tstowe

Technical User
Apr 29, 2003
65
US
I have a typical New Record button on my form and it does create a new record when pressed. What I would like is for the cursor to appear in the first field to enter new data instead of me having to click in the field (after clicking the new record button).

Thanks ahead of time.

Tony
 
After your code to add new record you need the following

Me.fieldname.SetFocus


Dave
 
Where do I put that tidbit of information?

Thanks

Tony
 
Hi,

or you can set the tab index for the field - either autmatically (menu: View >> Tab Order ... ) or explicitly (feild Properties >> Tab Index (start at 0) ).

Automatically works left to right, top to bottom, but does rely on accurate field placement on the form.

Cheers
 
Are you using VBA to add a new record or are you using macros?

Dave
 
For VBA it would look like this...

Private Sub Add_Click()
DoCmd.GoToRecord , , acNewRec
Me.textboxname.SetFocus
End Sub

For a macro I would have to check.

Dave
 
Dave,

Do I place your code somewhere in the button's properties?
 
Go to the properties of the button. Click the tab labeled Events. There you will see On Click. Click the little button at the end with the three dots. You need to select Event Procedure or Code builder (i can't remeber which options come up).

Anyway, that is where you need to paste the code.

Hope this helps. Let me know if you need more info.

Dave
 
That was too easy, now that I know where to put the code.

It works like a charm. Thank you for your quick response and I appreciate your time and patience on what probably appeared as too simple.

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top