Placing focus in desired control of subform

G

Guest

I have a SubForm with several textboxes. (txt1, txt2, ...). the Main Form
has buttons cmdNext (DoCmd.GoToRecord , , acNext) and cmdPrev. When I click
Next, say, the next record shows as expected and the subform updates as it
should. But I'd like the cursor to go back to the same textbox it was in on
the previous record. If I'm in txt19 then click cmdNext, I want the cursor
to return to txt19. Is this easy to do?

thanks
 
A

Arvin Meyer [MVP]

You can create a form level static variable and store the name of the
control in that variable. In the Current event of the form access the
variable and SetFocus to that control.
 
G

Guest

Arvin - thanks for your prompt reply

I'm a bit new at this, but trying my best to learn. Could you spell this
out just a little more for this newbie? Lets say I'm in txt23 of subform
sfrmCity then click cmdNext on frmMain. Exactly where would I declare the
static variable and what is the syntax? Then, what code might go in
sfrmCity's Current event?

muchly appreciated
 

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

Top