Calling Subs in a Subform

EricTheRed

Registered User.
Local time
Today, 04:27
Joined
Aug 7, 2003
Messages
27
In my continuing quest to create a functioning contact management database, I have come across this problem:

I have a main "contact" form, on which is displayed a "specific contact info" subform. When a user clicks a button on the main form, I would like to call a sub on the subform (specifically to change the displayed record). Unfortunately, its not as simple as placing the button on the subform (for a variety of design reasons my employer has foisted upon me). Although this seems like a simple task, I can't seem to get it to work. I've tried code along the lines of:

Me.frmSubform.DoThisSubPlease

But to no avail. Help, please? Thanks in advance!
 
It's actually pretty easy and you almost got it:
Me.frmSubform.Form.DoThisSubPlease

Important thing: the DoThisSubPlease must be declared as public (or just without the private prefix before the Sub declaration).

The syntax for this is the same as the syntax required for referring to a subform control from the mainform. You need to use the "Form" keyword in there to refer to the subform contents and not the subform object itself.
 

Users who are viewing this thread

Back
Top Bottom