how can i tab off to another textbox? (1 Viewer)

paritosh_a

Registered User.
Local time
Today, 19:38
Joined
Oct 18, 2005
Messages
16
Suppose i have one form in which i have one more form pasted.
when i tab off the textboxes of first form, i want the tab to go to the textboxes of another form.
At present, it goes back to the first textbox in a form instead of going to the first textbox in subform.

How can i do this ?
help urgent
 

RuralGuy

AWF VIP
Local time
Today, 08:08
Joined
Jul 2, 2005
Messages
13,826
To move to a SubForm with the tab key requires code either in the LostFocus event of your last control on the MainForm or the GotFocus event of a practically invisible dummy transparent and small (1px x 1px) TextBox. It requires 2 SetFocus lines:
Me!SubFormControlName.SetFocus
Me!SubFormControlName.Form!YourControl.SetFocus

Using your control names of course.
 

borisbruno

Registered User.
Local time
Today, 08:08
Joined
Oct 14, 2005
Messages
39
RG,

I'm having a similar problem, but I want to tab from one subform to another subform on the same main form. I can get it to do this by putting Me.Parent![subHouseholdMembers].SetFocus in the LostFocus event of the last control of subform Proofs, which is the subform I am coming out of. This does take me to the HouseholdMembers subform.

The problem is that I can't get a line of code to work that will always set the focus to the first control of the HouseholdMembers subform. I've tried a variety of lines and tried them in different events. I've even tried splitting the two lines of code, putting one in the LostFocus event of one control and the other in the GotFocus or Enter event of a different control.

My issue is that the cursor returns to the spot it was at when I left the second subform if for some reason I go out of the subform and then tab back into it. Not a big thing, but irritating. I would like the cursor to always go to the first control.

Sorry for interrupting. Charlotte
 

RuralGuy

AWF VIP
Local time
Today, 08:08
Joined
Jul 2, 2005
Messages
13,826
Hi Charlotte,
It requires two SetFocus lines as I have said. The first one sets the focus to the SubFormControl and the second sets the focus to the particular control on the SubForm:
Me.Parent![subHouseholdMembers].SetFocus
Me.Parent![subHouseholdMembers].Form!YourControl.SetFocus
 

borisbruno

Registered User.
Local time
Today, 08:08
Joined
Oct 14, 2005
Messages
39
RG,

Thanks for responding. I entered the lines as you suggested, but it gives me a run-time error "Object doesn't support this property or method." What am I doing wrong?

Charlotte
 

RuralGuy

AWF VIP
Local time
Today, 08:08
Joined
Jul 2, 2005
Messages
13,826
Which line is causing the problem? Did you replace YourControl with the name of your control?
Me.Parent![subHouseholdMembers].Form!YourControl.SetFocus
 

borisbruno

Registered User.
Local time
Today, 08:08
Joined
Oct 14, 2005
Messages
39
RG,

It seems like the line that sets focus to the individual control is the problem, though I don't know why. Here's what I've tried in the LostFocus event of the last control of the first subfrom:

Me.Parent![Names of Household Members].SetFocus
Me.Parent![Names of Household Members].Form!MemLstName.SetFocus

The second line causes the run-time error. Is the problem that the name of the form and the subform are the same? I know what you are telling me is right, because I've seen these lines of code in various formats listed as the cure at several different places. I just don't understand why I can't get it to work.

If I use just the first line of code, the focus does indeed go to the subform control. However, I can't control which field the cursor shows up in.

Thanks for taking the time to answer me. Charlotte
 

RuralGuy

AWF VIP
Local time
Today, 08:08
Joined
Jul 2, 2005
Messages
13,826
Hi Charlotte,
Let's try it without any bangs "!":
Me.Parent.[Names of Household Members].Form.MemLstName.SetFocus
 

borisbruno

Registered User.
Local time
Today, 08:08
Joined
Oct 14, 2005
Messages
39
RG,

I tried it this way but it still gives the same error. I even tried it with the bang out of the first line as well ... still the same error. Do I need to put the second line of code in an event in the subform control?

Charlotte
 

RuralGuy

AWF VIP
Local time
Today, 08:08
Joined
Jul 2, 2005
Messages
13,826
Put a test TextBox on the main form with the ControlSource set to:

=[Names of Household Members].Form.[MemLstName]

And see what you get.
 

borisbruno

Registered User.
Local time
Today, 08:08
Joined
Oct 14, 2005
Messages
39
It displays the same name as in the Household Members subform MemLstName field.
 

RuralGuy

AWF VIP
Local time
Today, 08:08
Joined
Jul 2, 2005
Messages
13,826
OK then, try this SetFocus code:
Me.Parent![Names of Household Members].SetFocus
Me.Parent![Names of Household Members].Form.[MemLstName].SetFocus
 

borisbruno

Registered User.
Local time
Today, 08:08
Joined
Oct 14, 2005
Messages
39
I'm setting this in the LostFocus event of the last control on the first subform? If so, it still throws the same run-time error as before.
 

RuralGuy

AWF VIP
Local time
Today, 08:08
Joined
Jul 2, 2005
Messages
13,826
Hi Charlotte,

The name of the control on the SubForm is LstName not MemLstName so:

Me.Parent![Names of Household Members].Form.LstName.SetFocus

will work. I got the mdb from your other thread.
 

borisbruno

Registered User.
Local time
Today, 08:08
Joined
Oct 14, 2005
Messages
39
AAAHHHHHH!!! Okay, so I'll wear the dunce cap for the rest of the day! Thanks so much for your help. That's the biggest frustration in doing this solo project, not having another readily available pair of eyes to take a look at what I'm doing.
 

borisbruno

Registered User.
Local time
Today, 08:08
Joined
Oct 14, 2005
Messages
39
Ouch! Well, I tried to explain to the food bank volunteers that my skills were entry level at best, but you know that old saying about beggars not getting to choose. Go ahead, as gently as you can, tear it apart. I'll do my best to keep my ego out of the way. :eek:
 

RuralGuy

AWF VIP
Local time
Today, 08:08
Joined
Jul 2, 2005
Messages
13,826
My reply was really generic. There are *always* more to go. Let us know when you get to them! :D
 

Users who are viewing this thread

Top Bottom