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!

referencing a subform field in vb code on main form? 3

Status
Not open for further replies.

buckner400

IS-IT--Management
Aug 1, 2001
1
US
I have a form with a sub-form.
A user of database would enter data on the sub-form.
There is a close button on the main form.
I would like to program this button to test to amke sure all the required fields on the subform were filled out.
How do I do this, I am having a difficult time referencing fields on the subform?
Is there a specific syntax to do this with?

Thanks,
Brian
 
"The complete syntax is rather complex and not at all obvious"

Thanks to Letwin/Getz/Gilbert

Forms("YourFormName")"SubFormControlName").Form.Controls("YourControlName")

 
Actually, the syntax is:

Forms!MainFormName!SubFormName!ControlName

But, you do not want to test the subform controls at the mainform level. You should not allow the user to leave the subform record until all required fields have been validated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top