Dlookup in a subform

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
 
R

Roger Carlson

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.
 

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

Similar Threads


Top