Syntax HELP

N

NEWER USER

I need some help verifying the correct syntax when referencing a subform on a
main form. Some examples I have are:
Forms!frmProduct!fsubRelations!GPM.ColumnHidden = -1
Forms!frmProduct!fsubRelations!Cost.Requery
"Number = Forms!frmProduct!fsubRelations!Number"

OR should I be writing?

Forms.frmProduct.fsubRelations.Form.GPM.ColumnHidden = -1
Forms.frmProduct.fsubRelations.Form.Cost.Requery
"Number = Forms.frmProduct.fsubRelations.Form.Number"

Any help appreciated.
 
J

John W. Vinson

I need some help verifying the correct syntax when referencing a subform on a
main form. Some examples I have are:
Forms!frmProduct!fsubRelations!GPM.ColumnHidden = -1
Forms!frmProduct!fsubRelations!Cost.Requery
"Number = Forms!frmProduct!fsubRelations!Number"

OR should I be writing?

Forms.frmProduct.fsubRelations.Form.GPM.ColumnHidden = -1
Forms.frmProduct.fsubRelations.Form.Cost.Requery
"Number = Forms.frmProduct.fsubRelations.Form.Number"

Any help appreciated.

Access is smart enough to disentangle some of these, but the proper syntax is

Forms!NameOfMainform!NameOfSubform.Form!NameOfControl

For an action, use

Forms!NameOfMainform!NameOfSubform.Form.Requery

or whatever form action you wish to do.

NameOfSubform is the Name property *of the Subform control*, the box
containing the subform object; this might or might not be the same as the name
of the form within the subform box.

If the code is on the main form, you can use Me! as a shortcut for
Forms!NameOfMainform.

The word Number is a reserved word and a bad choice for either a variable or a
control name.

John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Syntax Question 1
Open form on double click 7
More Detail Button 2
Modify Code on Form 2
HOW TO Simplify following code 2
need help with syntax 1
Access Reference Subform's Control 0
please help with simple syntax question 2

Top