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

Question about referencing a control on a subform....... 3

Status
Not open for further replies.

GWhiz

Programmer
Dec 16, 1999
49
US
Hi, folks!

Had a delete query which got its criteria value from a listbox control on a form when selection in listbox was clicked.

Criteria in query = Forms!MyForm!MyListbox

This worked just fine.

Then the form which contained the listbox control was changed to a SUBform. Now, criteria in delete query no longer can find the listbox control (form name remained the same, just became the Source for the subform).

Have tried multiple variations to get syntax in criteria correct, but cannot find the one that works.

How does one "address" a control on a subform so that a query can "find" it?

Thanks for any help. You folks have been VERY, VERY helpful in the past!

Respectfully,

drs84@hotmail.com
 
Hi,
I had a similar problem and posted the thread in the "Microsoft: Access Modules (VBA Coding)" forum. Robertd provided me with the correct syntax. Below is my question and his answer.

------------------------------------------------------------

CCTC1 (Programmer) Oct 4, 2000
Hi,
Real simple question: How do I referrence a subform or the objects in a subform that is open. One would expect that the form (being open) would be accessable through the forms collection ie. "Forms!MySubForm.MyTextBox" or even "Forms!MyParentForm.MySubForm.MyTextBox". I would like to referrence a list box, and various fields in the recordsource of the subform from a procedure, query, or parent form.
Thanks,
Rob Marriott
CCTC1
rob@career-connections.net

------------------------------------------------------------

Robertd (TechnicalUser) Oct 9, 2000
Hi Rob,

try
get value
avariable = Me![SubformName].Form![FieldName]

or
set value
Me![SubformName].Form![FieldName] = avariable

this will refer to what ever the current record is in the subform ie if you went to a record in the subform then executed code in the main form it will retrive the field value on that record. you might want to use a temp variant and test this before assigning it to a specific var type.

HTh


Rob Marriott
rob@career-connections.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top