Tab Order and SubForms (1 Viewer)

Luddite Lad

Registered User.
Local time
Tomorrow, 01:25
Joined
Aug 23, 2005
Messages
177
Is there a way of tabbing out of a SubForm once you have finished entering data into it?
 

Luddite Lad

Registered User.
Local time
Tomorrow, 01:25
Joined
Aug 23, 2005
Messages
177
To answer my own question :eek: Yes.

I just put a logical check on the "On Lost Focus" event of the first field of the (continuous) SubForm to check if it contained any data, if not it set the focus back on to the main form.

Should have thought a bit before I posted. Sorry :eek:
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 16:25
Joined
Sep 12, 2006
Messages
15,657
yes, but you are having to write code - it would be nice to have a keyboard way of doing this
 

fionahl

Registered User.
Local time
Tomorrow, 01:25
Joined
Jun 25, 2009
Messages
11
Hi all, I know this is an old thread, but I'm now tacking the same issue. I don't have much programming experience, so any help is greatly appreciated. I mentioned my issue in a thread, and John Big Booty suggested I read this thread for some suggestions.

I've tried a few combinations of code in the On Lost Focus field as suggested by Luddite Lad , however haven't had much success.

A few trials that didn't work:

Private Sub OccListID_LostFocus()
If Me.OccListID = Null Then
JobDescription.SetFocus
End If
End Sub

Private Sub OccListID_LostFocus()
If Me.OccListID = Null Then
DoCmd.GoToControl JobDescription
End If
End Sub

Private Sub OccListID_LostFocus()
If Me.OccListID = Null Then
DoCmd.GoToControl Forms!Employment!JobDescription
End If
End Sub


Are you able to paste the code you used? I'm not sure if I should be using Set Focus, or GoToControl...?


Many thanks!
 

SOS

Registered Lunatic
Local time
Today, 08:25
Joined
Aug 27, 2008
Messages
3,517
What I've done in the past is to put a small, almost invisible, text box (.01"x.01") on my subform and set the tab order so that is the one after the last field. Then in its Got Focus event I send it to the control on the main form:

Me.Parent.TheControlName.SetFocus
 

fionahl

Registered User.
Local time
Tomorrow, 01:25
Joined
Jun 25, 2009
Messages
11
Thanks for the suggestion SOS

I put that in, and it works a treat for the first time only when I tab through. The second time I tab through, it skips it and goes to the next control.

I don't understand why it works perfectly once only...
 

SOS

Registered Lunatic
Local time
Today, 08:25
Joined
Aug 27, 2008
Messages
3,517
You do have the correct tab order set, right?

Also, make the text box big until you have it working right so you can see if it manages to get into it.
 

fionahl

Registered User.
Local time
Tomorrow, 01:25
Joined
Jun 25, 2009
Messages
11
I have the tab control set up, so that after the first two controls on my form, it goes to the subform, then to the rest of the controls. Then on the subform, my two items are my text box (with the important stuff in), and my unbound text box with this in On Got Focus:

Private Sub Text2_GotFocus()
Me.Parent.JobDescription.SetFocus
End Sub


Still works perfect first time, but then not on subsequent occasions. I discovered it also prevents me from clicking back into the subform (ie text box) to edit. It is as if it is locked. Bizarre!
 

fionahl

Registered User.
Local time
Tomorrow, 01:25
Joined
Jun 25, 2009
Messages
11
Fixed it!

On the control before my subform, I have the following:
Private Sub JobEnd_Exit(Cancel As Integer)
Me!frmOccListFillerTable!OccListID.SetFocus
End Sub

Then, in the subform, I have my control (the combo box with all text), then a small box (unbound) after, with:
Private Sub Text7_GotFocus()
Me.Parent.JobDescription.SetFocus
End Sub

Somehow its working.. hopefully it'll stay that way!

Thanks for your help SOS!
 

Users who are viewing this thread

Top Bottom