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

tab out of subform 1

Status
Not open for further replies.

katiekat

Technical User
Jun 6, 2000
300
US
Is there a way, when you're tabbing through a form, to get out of a subform with a keystroke instead of having to use the mouse?

Just wondering.

Thanks!
Kate

Holy tek-tips batman!:-0
 
Many ways to skin a cat in MS Access. This is just one. In the On Lost Focus event procedure of the last field of the subform, set the focus to the first field on the main form like so...

Forms![MainFormName]![FirstFieldName].SetFocus

Just a thought...



ProDev, MS Access Applications
Visit me at ==> Contact me at ==>lonniejohnson@prodev.us

May God bless you beyond your imagination!!!
 
That would work, but I may be entering more than one record in the subform, so I wouldn't necesarily want to be kicked out after the last field.

I was kind of looking for a keystroke that would move me on to the next tab stop in the main form.

Thanks though!
Kate

Holy tek-tips batman!:-0
 
Hmmmmm....

You could put code in the KeyPress event for the textbox in question to send the focus back for a particular key, like the enter key. It would look something like...

If KeyAscii = vbKeyReturn Then
Forms![MainFormName]![FirstFieldName].SetFocus
End If

Happy coding!


ProDev, MS Access Applications
Visit me at ==> Contact me at ==>lonniejohnson@prodev.us

May God bless you beyond your imagination!!!
 
Fantastic!

Thanks a bunch!

Kate

Holy tek-tips batman!:-0
 
Hi Katie,

What i happened to discover once is Ctrl-Tab.
It only helps to get out of the subform, there's no inverse function with shift or so (but you didn't ask for that in the first place).
This keystroke that seems to work most of the time, but I guess that when the focus within the the subform is on a tabstrip, the keystroke will affect that tabstrip.
Actually it seems like it takes you to the next control in the tab-order on the main form, and shift-ing it takes you to the previous.

Daan
 
YES YES YES!

That is EXACTLY what I was looking for!!!!!


THANKS! You have no idea. This may seem trivial to you, but it will same me so much time!

THANKS AGAIN!!!
Kate

Holy tek-tips batman!:-0
 
To LonnieJohnson

Thanks for your second suggestion on 17th June, regarding the KeyPress event. Just what I needed.

You have a star from me!!

Best wishes

Magnetar [atom]
 
This is exactly what I need to do, however I put in the same code in my last field on my submform just as indicated in the thread... it's not working for me.

The focus still goes to the first field in the subform instead of jumping to the main form.

Help??

-Tiffany

-Tjones76
 
Is the field that you are sending the focus to a field that allows the focus? Be sure the tab stop property is set to Yes and the Enabled property is set to Yes.

Just a thought...

ProDev, MS Access Applications
Visit me at ==> Contact me at ==>lonniejohnson@prodev.us

May God bless you beyond your imagination!!!
 
If it isn't resolved yet, you could try the keydown event in stead.

When a keystroke causes focus to move to another control (enter/tab), the keydown event is recieved by the first control, whilst the keypressed event is received by the next control (first control of the subform).

Sample code:

[tt]if keycode = vbkeyreturn then
Me.Parent!FirstControlName.SetFocus
keycode=0 ' cancelling the enter key...
end if[/tt]

Roy-Vidar
 
I am finding that both the keydown and keypress events "sort of" get me to where I want to go but not consistently. My set up is that I have a main form with 2 subforms. I want to be able to tab/enter across 2 text boxes on the main form then straight into the first 2 text boxes on the first subform and then straight into the first 2 text boxes on the 3rd subform. In essence, I am visually tabbing/entering across a row of 6 textboxes on my form (but the user is unaware that the form is made up of a main and 2 subforms). Here is the code I am using:

Private Sub BG2_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyTab Or vbKeyReturn Then
Forms!frmcsauditflex![subformFLEXBillingGroups]!.SetFocus
End If
End Sub

What I am finding is that often, once I hit tab or enter from the 2nd text box, it takes me to the second text box on the subform. Also, if I enter the number 1 in the text box, it jumps around everywhere....

Any suggestions?

Dawn Coleman, Business Analyst
UnumProvident Corporation

PLEASE RECYCLE AND ENCOURAGE YOUR OFFICE/COWORKERS TO DO SO AS WELL.
 
Morning Sun,

Have you set the cycle property of the first text box on the subform to Current REcord? That worked for me to solve this problem.

imbriani
 
Think perhaps MorningSun's question here (the jumping to the second control of the sub) is answered in my previous reply, one need to cancel the keystroke. Difference between the keydown and keypressed is that keypressed uses KeyAscii, see below for this version.

In addition, to make the iftest work, one need to do the comparison on both conditions:

[tt]If KeyAscii = vbKeyTab Or KeyAscii = vbKeyReturn Then
KeyAscii = 0 ' cancel the keystroke
...[/tt]

The behaviour after pressing 1, I don't understand. There might be other event's firing?

Roy-Vidar
 
I had coded :
If KeyAscii = vbKeyTab Or vbKeyReturn Then
Instead of:
If KeyAscii = vbKeyTab Or KeyAscii = vbKeyReturn Then

When I fixed this it worked fine. Guess it was confused.
THANKS SO MUCH!

Dawn Coleman, Business Analyst
UnumProvident Corporation

PLEASE RECYCLE AND ENCOURAGE YOUR OFFICE/COWORKERS TO DO SO AS WELL.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top