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

Referencing Controls on a Tab 1

Status
Not open for further replies.

swest13

Programmer
Feb 13, 2003
3
0
0
US
I'm trying to reference a form control from a query. The control is on a subform that is on a tab. I can't get the reference correct. I'm exhausted from the iterations. I'm looking for anyone that can tell me how to reference it, given MainForm, TabPage, SubForm, and Control. For example, is it:

Forms![MainForm]![TabPage].[SubForm]!Control?

Please help, I really appreciate it!

 
Hello swest13,
I believe that you are missing the
Code:
Form
object and that you should ignore the
Code:
Tab Control
object. Try the following code:
Code:
Forms!MainForm.SubForm.Form.Control

Hope that helps,
Robert Professional, affordable, Access database solutions and assistance
 
Thanks, but I still can't get it to recognize this reference. It works if I have it on a subform only, but then it doesn't work when I put it on a tab. Any more thoughts? Thanks again.
 
Nevermind, I found my error. You were right. Thanks!
 
I am in a similar quandry with this one!

I have a main form which has a subform on it. The subform has a tab control with 2 tabs (2nd tab contains 3rd level subform)

I have a combo box on the main form, which after update I would like it to set the focus on Tab 1 of the subform, controlA.

Prior to putting the tab control on the subform, I could get the focus onto ControlA no problem. I think I need to be able to dictate that it's on tab1 that I need to go as well, but cannot for the life of me fathom it!

Any ideas? NKA

The answer's always easy - if you know it! ;-)
 
What you may find useful is a tool to resolve control names. It works something like this (may need tweaking)

Dim Object as Object
Set Object = Screen.ActiveControl

dim Heritage as string

do while true
if MyObject.Parent is nothing then exit do
Heritage = "(""" & MyObject.Name """)" & Heritage
loop

Heritage = "Forms" & Heritage

This *is* off the top of my head, but the idea is to trace a control's lineage.

Then, you want to put this bit of code in a function, then use the AutoKeys macro to associate a control key combination with executing the function.

You can then get the fully qualified name of any control. Such a name should suffice for setting focus.

That being said, I have found that sometimes you need to set focus to the control containing the sub-form prior to setting focus to a control on the sub-form.
 
Solodroid, please help!!

I am trying to accomplish something similar.
I have a main form, frmMain.
On that form, I have my tab control.
On my tab control I have a Subform, frmEntry, which contains another subform, sfrDetails.
The query is in my recordsource for the subform sfrDetails.

I am trying to reference in the query the control cboProduct that is located on the frmEntry form.

I have tried the following syntax -

[Forms]![frmMain].[form]![frmEntry].[form].[cboProduct]
(which i SWEAR worked the first time, now errors)

[Forms]![frmMain].[frmEntry].[form].[cboProduct]

with both tries, I get a 'expression is typed incorrectly or is too complex to be evaluated, blah, blah, blah' error.

The other syntax I have tried is -
[Forms]![frmMain].[form]![frmEntry].[cboProduct]
this one gives me a parameter prompt, but everything is referred to correctly (ctl names, etc.)

any help would be IMMENSELY appreciated!!!!
 
I, too, have a related problem. I have a form that has a FileNumber and then 7 tabs. I have the Record Source set as a query that combines 7 tables. What I want to do is pass that file number to each of the 7 tabs. As of right now, I have to manually input the FileNumber on each tab.

I want to just enter the file number at the top and have it passed to each tab so that when the data is entered the FileNumber does not have to be entered 8 times total.
 
Moss,

With the help of one of my coworkers, we were able to get something working, but I'm not sure how well I'll be able to explain it.

The query that I'll be talking about is the recordsource of my form that is located in the tab control. It is a subform of another form.

Here's what we did.

In the DESIGN view of the query, go to the first blank column. Place your cursor in the top line (field) and invoke the build wizard to do an IIF statement. In the IIF statement, you will need the following format -

IIF([tblname].[tblField you are comparing] = [name of form], true, false)

This should create an expression, usually Expr1.

Now, instead of entering the name of the form, click on the forms folder located at the left of the build screen and manuever to the form/control that you are comparing to.
This will produce the correct syntax that you need.

Be sure to also have your form open w/the criteria in it so the query can run correctly.

From here, you can run the query and make sure the IIF statement is working. If it isn't, #Error will show in the Expr1 column, otherwise True/False shows.

Now, back in the DESIGN view, for the field EXPR1, in the Criteria line, enter

=True

This will now only return all values that evaluated to True with the IIF statement.

Here's what one of my expr's looks like -
IIf(([tblGrid].[Prod]=[Forms]![frmMain]![frmEntry].[Form]![cboProduct]),True,False)

I Swear i tried the exact same syntax in a direct = statement in the query and it didn't work, but this seems to work fine without any glitches. We really don't know what the difference is, but as long as this is working I'm happy. :)

Good luck, and I hope I've explained it well enough for you!
Janel
 
Here's and example how I reference a control on my subform from the Main Form to make a control visible:

Me.subform!ControlName.Visible = True
 
anasazii,

Thanks for the response.

This thread has a lot going on. I will start a new one called "Passing one value to multiple tabs" to eliminate confusion.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top