DLookup Criteria In A Subform

  • Thread starter Thread starter Jack
  • Start date Start date
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
 
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?
 
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
 
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
 
Back
Top