Full Version: How To Move From A Field In A Subform To The Main Form With VBA
UtterAccess Forums > Microsoft® Access > Access Forms
RubyB
I have a form with one subform. When in data entry mode, I begin with most fields disabled. As the user completes the available fields, the next fields are enabled and focus set to them as appropriate.
've come to the point where the user is in the final field in the subform. How can I write VBA code (After Update) that will set focus back to the main form and then perform the final "reveal" of the remaining objects to be filled in?
doctor9
RubyB,
Is the user not able to use CTRL-TAB to escape the subform and return to the main form? Do you need to bypass this in some way?
If so, I think you just need to use something like:
CODE
Me.Parent.Controls("Control Name Here").SetFocus

Hope this helps,
Dennis
RubyB
It worked as soon as I realized that I didn't need to substitute Me.frmStudent for Me.Parent.
My users won't be able to remember Ctrl + Tab. I'm lucky if I can get them to use the tab key EVER instead of mouseing around for everything. I'm dumbing the form down now to force completing of fields so they don't skip them.
Many thanks.
doctor9
Ruby,
Glad to help!
If it's any consolation, my first database - one used to track bills we pay - includes a label control just below the continuous subform that lists the bill's line items. It reads: "Use CTRL-TAB to continue to the Tax field". It's been there for over twelve years.
Dennis
RubyB
That's an idea. A good one.
ice hat.
ScottGem
Just as an aside here, you don't have fields on a form. You have controls that may or may not be bound to fields in a table. This is a subtle but important distinction. And it matters here because you may want to set focus to a control like a command button on the main form.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.