Link to home
Start Free TrialLog in
Avatar of Annmv888
Annmv888

asked on

Reference Controls on subforms

I have the following forms:

frmMembers – Main form
frmAllMeasures – subform on Main, this has a control called Letter
frmC2442 – subform on frmAllMeasures.  There will be five of these with different numbers stacked on top of each other.

The C2442 form (and all the others) will open with the Visible property set to “No”.  So the only forms that show will be frmMembers and frmAllMeasures.

From a dropdown individual members can be chosen.  Once a member is chosen the Letter control will fill in with C2442 (or one of the other numbers).  At that point I would like to change frmC2442 (or one of the other numbers) visible property to true and set the focus so it’s on top and shows and each time this control value changes the corresponding form shows.

I’ve tried so many different ways to write vba referencing controls on Main, sub and subforms and I just can’t get it right.

Thanks for any help you can give me.
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

upload a copy of db to make the posting of comments minimize

for the meantime look at this link
http://access.mvps.org/access/forms/frm0031.htm
Rey's link should get you straight, but be aware of the concept of Subform CONTROLS and how they are named. This can trip you up, so be careful when determining names.

A Subform CONTROL is a control you put on a form, just like a Textbox or a Combobox. When you refer to a Subform, you must be sure to refer to the Subform CONTROL first, and then the Form property of that.

When you add a Subform to a Form, Access will name it in specific ways depending on how you add it. If you drag a form onto another, Access will embed it, and will name the Subform the same as the form you're embedding - so if I have a From named "frmInvoice", and I embed that on a form named frmCustomer, Access would name the Subform Control "frmInvoice", and I'd refer to it like this (from frmCustomer):

Me.frmInvoice.Form.SomePropertyOrMethod

One way to be sure you're working with a Subform Control - it will have only two Events (On Enter and On Exit), and will have properties named Source Object, Link Master Field, Link Child Field, and Filter On Empty Master. If you click on an object in your form and view the Property Sheet, and you see those Events and those Properties on the Data Tab, then the control you have highlighted is the Subform CONTROL, and is the name you use in place of "frmInvoice" in the line above.
Avatar of Annmv888
Annmv888

ASKER

I had been using the linked document any time I have needed to do this and always have a hard time.    I spent hours trying to get it written correctly and could not, that is why I posted.

I need to substitute dummy data for real data in my database.  I will upload it once I am done.
Here is the database.  Jay Doe, Justin Doe and Jennifer Doe are three members who get letter C2442.
MemberSurvey---Copy.accdb
The Members button on the Switchboard is the one to get to the forms.
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oh WOW!!  That worked perfectly!!!  I never would have gotten that.  One of my attempts was to use the OnCurrent event from the main form and make them visible.  I will definitely be able to use this in the future.  Thank you so much!