DLookup Criteria In A Subform

J

Jack

What is the syntax for the criteria in DLookup in a subform to refer to a
control (MyControl) on the subform? I have tried the following and none seem
to work:
"[MyField] = " & Forms!NameOfMainForm!NameOfSubformControl!MyControl
"[MyField] = " & Forms!NameOfSubform!MyControl
"[MyField] = " & NameOfSubform!MyControl

The subform control and the subform have the same name so the last criteria
could refer to either.

Thanks,
Jack
 
K

Ken Snell [MVP]

This one should work, assuming that you use the correct names:

"[MyField] = " & Forms!NameOfMainForm!NameOfSubformControl!MyControl

Where are you using this code step? In the subform itself? In the main form?
somewhere else?
 
J

Jack

Thanks for responding!

I'm using it in a field in a query for the recordsource of a subform.

Jack



Ken Snell said:
This one should work, assuming that you use the correct names:

"[MyField] = " & Forms!NameOfMainForm!NameOfSubformControl!MyControl

Where are you using this code step? In the subform itself? In the main form?
somewhere else?

--

Ken Snell
<MS ACCESS MVP>


Jack said:
What is the syntax for the criteria in DLookup in a subform to refer to a
control (MyControl) on the subform? I have tried the following and none
seem
to work:
"[MyField] = " & Forms!NameOfMainForm!NameOfSubformControl!MyControl
"[MyField] = " & Forms!NameOfSubform!MyControl
"[MyField] = " & NameOfSubform!MyControl

The subform control and the subform have the same name so the last
criteria
could refer to either.

Thanks,
Jack
 
K

Ken Snell

Post the real names of the subform control, the control in the subform, and
the main form.

--

Ken Snell
<MS ACCESS MVP>

Jack said:
Thanks for responding!

I'm using it in a field in a query for the recordsource of a subform.

Jack



Ken Snell said:
This one should work, assuming that you use the correct names:

"[MyField] = " & Forms!NameOfMainForm!NameOfSubformControl!MyControl

Where are you using this code step? In the subform itself? In the main form?
somewhere else?

--

Ken Snell
<MS ACCESS MVP>


Jack said:
What is the syntax for the criteria in DLookup in a subform to refer to a
control (MyControl) on the subform? I have tried the following and none
seem
to work:
"[MyField] = " & Forms!NameOfMainForm!NameOfSubformControl!MyControl
"[MyField] = " & Forms!NameOfSubform!MyControl
"[MyField] = " & NameOfSubform!MyControl

The subform control and the subform have the same name so the last
criteria
could refer to either.

Thanks,
Jack
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top