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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Confused by subform naming conventions 3

Status
Not open for further replies.

kupe

Technical User
Sep 23, 2002
376
The form “frmMatrix” has two subforms. First is subform “frmWorkers”, and the second subform is “frmTransfers”.

To email, and to print a document (via Word) from the db, I need to refer to fields on the Form, and the SubForm “frmWorkers”.

Advice from Microsoft says I have to refer to subform controls and then controls. After an hour or two of various attempts, I’m left puzzled and answerless.

Most obliged if an expert could tell me how these two fields should be described:

1. frmMatrix.txtSName, and
2. frmWorkers.cboWork

I mean, should it be Forms!frmMatrix.txtSName and Forms!frmMatrix.frmWorkers.cboWork ? - though this doesn’t work.
 
My guess (provided frmMatrix is an open mainform):
Forms!frmMatrix!txtSName
Forms!frmMatrix!frmWorkers.Form!cboWork

Have a look here:

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks, PHV, I'll try that. (Should the last Form be Forms! plural?

Thanks for the ulr. But that is far from clear - to me, and my limited experience, that is. I've wasted hours trying to make sense of it.

Cheers
 
Another way is to follow the Expression Builder (loaded forms ...).

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PH
When I say 'far from clear' I mean Microsoft's contribution!
Cheers
 
Or, maybe this:

When you place a subform on your form, you are placing a subform control. That control has various properties, methods, and events. One of its properties is the actual form that is associated with it. So when you are on the main form and want to refer to properties or controls of the subform, it is not enough to refer just to the subform control (because the control is a separate entity). You must refer to the Form property of the subform control before you can reference the actual subform's objects, i.e.:
Code:
Me![blue]SubformControlName[/blue].[purple]Form[/purple]![blue]NameOfControlOnSubform[/blue]
Or...
Code:
Me![blue]SubformControlName[/blue].[purple]Form[/purple].[purple]SubformProperty[/purple]
Or...
Code:
Me![blue]SubformControlName[/blue].[purple]Form[/purple]![blue]NameOfControlOnSubform[/blue].[purple]PropertyOfControlOnSubform[/purple]
HTH,

Ken S.
 
PH
Your guess works really well, PH. Thank you. Very much obliged to you.

Thanks, Ken S, for the url and for explaining. I confess that when I have to find a quick answer, finding what is a Name of Control and what is a Property of ControlOnSubform confusing.

Going by PHV's code, SubformControlName is the name of the form.

NameOfControlOnSubform must be txtSomething.

But then what is a PropertyOfControlOnSubform?

When in haste one looks at the form Properties, these parts of the form are not named that way. Well, at this present stage, I find it a bit confusing. Perhaps after a while, the smoke clears.
 
Hi, kupe:

If you use the subform wizard to place your subform control, by default the name of the subform control and the name of the actual (sub)form to which the control is bound are indeed the same. But this is NOT NECESSARILY SO. For instance, the name of the subform control could be something generic, like "Subform8", whereas the name of the form contained in the control (i.e. the name of the subform as it appears in the forms list of the Access window) might be "frmMySubform". If you open the property sheet of the subform control, under the "All" tab you will note that the first two fields are "Name" and "Source Object." Name is the name of the control; source object is the name of the form to which the control is bound. This concept is true of any bound control, and I almost always make it a point to give the control a different name from the object to which it is bound.

So, in my example, using the control and subform names above, with a textbox named "txtSomething" on the subform:
Code:
Me![blue]Subform8[/blue].[purple]Form[/purple]![blue]txtSomething[/blue]
...is the syntax to refer to the "txtSomething" control on the "Subform8" subform. Note that I used the name of the subform control ("Subform8"), not the name of the subform control's source object ("frmMySubform").

Then if I wished to refer to a property of an object on the subform, for instance, the Visible property of "txtSomething":
Code:
Me![blue]Subform8[/blue].[purple]Form[/purple]![blue]txtSomething[/blue].[purple]Visible[/purple] = False
Does that help explain it a little better?

Ken S.
 
Yes, it does, Ken S, and very much obliged to you. I've copied it and will save it in my #1 notebook.

Thanks very much for going to all that trouble. It is appreciated very much. Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top