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!

How do I reference a control on a subform in a tab control? Get error

Status
Not open for further replies.

smsmail

Programmer
Aug 11, 2010
105
US
Hello all,

I am trying to reference a control on a subform that is in a tab control. Below are the hierarchy of controls. The parent form is unbound, it is just a menu to the other pages in the tab control.

Parent form - Production
Page - Page2
Subform - Client
Control - ClientName

How would I reference this? what I have tried, has failed.

Thanks so much for your help!

 
How are ya smsmail . . .

Try:
Code:
[blue]   [Client].Form!ClientName[/blue]
You reference as if the tab control were'nt there.

Your Thoughts? ...

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Where do you want to reference the control from? Is this in the criteria of a query? Is it in a standard module? Is it in a module or control source on the parent form?

It's kinda like asking "how do I get to the grocery store"? It depends are where you are starting from.

Duane
Hook'D on Access
MS Access MVP
 
Hi AceMan1

I tried your suggestion

Code:
 rs1.Open "select * from client where clientname = """ & [b][Client].Form!ClientName [/b] & """;"
and got a runtime error '2465': Jobtrack can't find the field '|' referred to in your expresssion.

I then tried, and it worked:
Code:
 rs1.Open "select * from client where clientname = """ & [b]Me!ClientName [/b] & """;"
Why did the above work? I am referencing the control from the subform.

Again, thank you for your help
 
Hi dhookom,

I am referencing the control from within the subform itself. I was able to get it to work using:
Code:
rs1.Open "select * from client where clientname = """ & [b] Me!ClientName [/b]  & """;"

Another question, when I navigate to another page/subform in the tab control and go back to the previous page/subform I loose the data that was displayed, how do I keep that data displayed on the page/subform?

Thanking you for your help in advance!



 
Dhookom,

You are right. I had some code in an event, that caused the controls to be blank.

Thanks again for your help!

More questions may follow.
 
smsmail . . .

I took a chance that you wanted to reference the subform from the mainform (this is what [blue]dhookom[/blue] was after ... referenced from where?). Now that you've shown its part of an SQL statement, things change. Within an SQL statement ... the full reference has to be given ... as in:
Code:
[blue]Forms!MainFormName!subFormName.Form!ClientName[/blue]
I hope you understand.

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top