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

Multiple pages with continuous subforms set focus 1

Status
Not open for further replies.

JennieL

Technical User
May 16, 2005
19
CA
Hi,

I have a main form with a subform containing multiple pages (tabs). Each page contains a continuous subform.

I want to set focus on a control on another page, after user error. However, I can't seem to get the code right.

Can anyone help me with referring to a control that is on a continuous subform, which is on a page (tab), which is on a control tab?

Thank you in advance,

JennieL
 
I assume you want to move from a control on one page on the subform to another page.

Assume that you want to move to a page on your subform called pgGoHere and the subform object on your main form is called sfrmManyPages. You would refer to the other page from your page on the subform using something like this:

me.parent.sfrmManyPages.PgGoHere.setfocus

Bob
 
Thanks for the response Bob.

That works great to get to PgGoHere.

Do you know whether it is possible to actually set focus on a control on PgGoHere?

Is to possible to :

Me.parent.sfrmManyPages.PgGoHere.mycontrol.setfocus

I get error message and never know whether its my code or just not possible. Perhaps I am getting error since subform is continuous?

Thanks again,

JennieL

 
I think you need to modify your statement to something like this:

Me.parent.sfrmManyPages.PgGoHere.mycontrol.controls.setfocus

I'm not sure if it should read "control" or "controls"

Bob
 
Hi Bob,

Sorry to be a pest, but I can't get past this one.

I can set focus on subform (Child54) with no problem.

However, trying to set focus on control is another story.

I have tried all these listed below with no luck.

Can you see anything funny?

'Me.Parent.Child54.SetFocus 'this works just fine
'Me.Parent.Child54.StatusA.Controls.SetFocus 'get error #438 = Object doesn't support this property or method
'Me.Parent.Child54.StatusA.Control.SetFocus ' get error #438
'Me.Parent.TabCtl47.Child54.StatusA.Controls.SetFocus ' get error #438
'Me.Parent.TabCtl47.Child54.StatusA.Control.SetFocus ' get error #438
'Me.Parent.Child54!Form.StatusA.SetFocus ' this dont work
'Me.Parent!StatusA.SetFocus ' nope
'Me.Parent.Child54!StatusA.SetFocus ' no error but not jump
'Me.Parent.Child54.Form!StatusA.SetFocus ' no error but no jump
'Me!Parent.Child54.Form!StatusA.SetFocus ' error = cant find the parent

Thanks Again,

JennieL
 
You need to first refer to the name of the control on the parent form before you include the name of the subform. So if your subform is called "Child54" and it is in the control called "ChldSubform54" you would refer to it as:

Me.Parent.ChldSubform54

Referring to a control on the subform would be something like:

Me.Parent.ChldSubform54.Form!Child54.StatusA.setfocus

(I'm not sure where the word Form (Forms) belongs in the statement. You may have to look it up or at least see what's available when the drop down lists appear as you write the statement.)

Bob
 
You also don't have to quote the name of your tab control or pages of it, as the control although sitting on a tab control is placed on the form its on.
 
Hi Bob (& Zor)

This is still not working for me. I must be missing something.

The subform is: child54
The tab control is: TabCtl47
The page is: EEinfo
The control I want to focus on: StatusA

As I mentioned, I can set focus no problem on the subform (child54), but having no luck getting to control.

I tried all of these below as well. Am I putting Form! in the wrong place?

'Me.Parent.TabCtl47.Form!Child54.StatusA.SetFocus -nope #438
'Me.Parent.TabCtl47.Child54.Form!StatusA.SetFocus -nope #438
'Me.Parent.Child54.Form!StatusA.SetFocus - no error no jump
'Me.Parent.Form!Child54.StatusA.SetFocus -nope #438
'Me.Parent.Child54.Form!StatusA.SetFocus - no error no jump

Thanks again!!

JennieL
 
If you are trying to set focus to a control on a subform try this:

Forms!NameofyourMainform!Nameofyoursubform.Form.Nameofcontrol.Setfocus

You donts have to include the name of your tabcontrol, as it is transparent between any controls that sit on it and the mainform

 
But what is the name of the control on your main from that contains the subform Child54? You have to first reference the control on the main form before you actually reference the name of the subform.

Bob
 
Hi Bob & Zor,

Thanks for the FAQ list...it is great for a User like myself.

I tried the long route suggestion and get the same results:

'Forms![F-BU Tabs]!Child54.Form.StatusA.SetFocus - no error no jump

'Me.Parent.Child54.Form.StatusA.SetFocus - no error no jump

I am coming down to the conclusion that I can't SetFocus like this when dealing with a "continuous" form. I think code messes up because I have not chosen a given record?

I will have to try something else.

Thanks for all your help!!!

JennieL
 
Forms![F-BU Tabs]!Child54.SetFocus
Forms![F-BU Tabs]!Child54.Form!StatusA.SetFocus

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi PHV,

That worked perfectly!!!!!

It takes two steps. That was my missing link.

Thanks for all your help....Everyone.

JennieL (happily skipping along)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top