Dlookup in a subform

  • Thread starter Thread starter jmagness
  • Start date Start date
J

jmagness

Hi all,

I am using a DLookup in a form that is a subform. If I
run the form alone the DLookup works great, but when I
run it as a subform it blows up. Any ideas?

Jay
 
Most likely, you are not referencing the control properly. You can't simply
say Me!Combo1 or Forms!MySubForm!Combo1, you have to start from the root
form. Another problem is that you don't reference the subform name itself,
but the name of the subform CONTROL on the mainform.

Assuming your main form is named MyForm, your subform control is named
MySubControl, the subform itself is named MySubForm and the control on the
subform you are referencing is MyCombo, then the DLookUp criteria would look
something like this:

DLookUp("SomeField". "SomeTable", "[Myfield] = " &
Forms!MyForm!MySubControl.form!MyCombo)

This assumes that MyCombo is a numeric. Notice the actual name of the
subform appears nowhere in this.
 
Back
Top