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 a control on a subform 1

Status
Not open for further replies.

Jackie

MIS
Feb 9, 2000
148
0
0
US
I have a main form with 2 subforms.

The subforms are within a tab control. Each subform is a tab.

I want a field on the 2nd tab to default to a field value on this 1st tab.

What is the correct syntax?
I currently have:
=[Forms]![frmPermits]![Subform]![sfrmInspections].[Permit]

I followed the below syntax from another thread:
[Forms]![MainForm].[SubForm].[Form].[Control]
 
The naming of controls is a problem for a lot of people until it is expalained clearly to them

Firstly remember that the subForm object has a name. This is the name you see when you look in the Database's Forms window and see the list of Forms you have created.

Also on the Main form the is a control called a subForm control that contains the subform. This subForm control has a name. When the subForm is created using the Access Wizard the subFormObject name and the subFormControl name are the same. HOWEVER, they do not have to be, and I personlly find it easier to keep a clear head by calling them differnt things

So the correct format is

Forms!MainFormName!subFormControlName.Form!ControlName


The other thing to note is that the use of Exclaimation Marks and Full Stops is critical.

Anything that is a System defined name ( Form ) in the case above has a full stop in front of it.
Anything that has a name that you name up has an Exclaimation Mark in front of it.



'ope-that-'elps.

G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.
 
OK.

Here is the syntax that I tried and I still get the NAME# error:

=[Forms]![frmPermits]![TabCtl0]![sfrmInspections].[Permit]

Main Form = frmPermits

Subform control = TabCtl0 (this is the object that contains the 2 subforms in tab format)

Subform name as in database window = sfmInspections
Tab 1 object = sfmInspections.permit

Remember, the field that I'm updating is on the sfmDetails form which is the 2nd tab.


 
Here is the syntax that worked:

=[Forms]![frmPermits]![sfrmInspections]![Permit]

The tab control did not have to be referenced.
 
The tab control did not have to be referenced.

Thats exactly what I was saying in my first post.




G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top