SetFocus to current field

  • Thread starter Thread starter MikeF
  • Start date Start date
M

MikeF

To prevent accidents, my forms are set to not allow edits.

When edits are required, I click a button whose code is the following:

Me.AllowEdits = True

Would like to add "stay on current field" to that code.
So in short, whatever field I'm on in the form when the EditCurrentRecord
button is clicked, that's where the focus needs to be set.

Assistance is appreciated.
Regards,
- Mike
 
MikeF said:
To prevent accidents, my forms are set to not allow edits.

When edits are required, I click a button whose code is the following:

Me.AllowEdits = True

Would like to add "stay on current field" to that code.
So in short, whatever field I'm on in the form when the EditCurrentRecord
button is clicked, that's where the focus needs to be set.


Well, when the EditCurrentRecord button is clicked, *that's* the current
control. <g> So what you really want is the previous control. Try this:

Me.AllowEdits = True
Screen.PreviousControl.SetFocus
 
Works great, thanx Dirk.
- Mike

Dirk Goldgar said:
Well, when the EditCurrentRecord button is clicked, *that's* the current
control. <g> So what you really want is the previous control. Try this:

Me.AllowEdits = True
Screen.PreviousControl.SetFocus


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top