Referencing the controls on a subform...

Ecron

Registered User.
Local time
Yesterday, 21:30
Joined
Aug 31, 2006
Messages
58
Hello,

I need some help with a piece of code for a db.

This code checks to see if the last three characters on a ControlSource.Tag property are "Req" and if they are, tests if it's null or = 0 and if it is then it outputs a msg box stating that the control.ControlSource is required. It does it for every control on the main form.

This has worked.

Now, i need to allow for multiple subforms to be located on the main form along with their controls being tested as well. I want to start another loop for each time the conrol on the mainform is a subform.

I have that done so far by using "If TypeOf ctl Is SubForm Then..."

This is the part i need help with. I want to search all of the controls on the subform when it is a subform. I need to search all of the controls on the subform then, and i'm not quite sure of the syntax.

I've tried various somethings like SUBFORMCONTROL.Controls but that hasn't seemed to work...

If someone could help me, that would be wonderful!
 
to reference a control on a subform

Forms!myMainForm!MySubform!mySubformControl

check the help topic on referencing control in expressions
 
heh. A quick fix for a simple problem.

My knowledge of the syntax is apparantly lacking...

Thanks Dennisk!
 
Oh, and some other FYI material:

When you place a subform on a main form, it actually resides within a subform CONTAINER and is not the subform. The container and the subform CAN (and frequently do) have the same name as the subform, and this is one instance where it actually works and makes it easier to refer to, but it doesn't have to be thus. A subform container when added by the wizard will name it the same as the subform it contains. If you manually put a subform on the main form, then the subform control will be named something like ActiveXCtl3 and won't, by default, be named the same as your actual subform. If you rename the control back to the subform name then it simplifies things. But, if you don't, then if you had a main form named frmMyMain and a subform named Sub1 and a container named ActiveXCtl3 you would refer to a text box named txtMyText on Sub1 by using:
Code:
Forms!frmMyMain.ActiveXCtl3.Form.txtMyText
 

Users who are viewing this thread

Back
Top Bottom