Dlookup Subform Problem

D

DubboPete

Hi legends

I have a subform which is master/child linked to the main form by
'Order'. In the subform, I have 'order', 'item' and 'Itemname'. The
'Itemname' field is a DLookup which works fine when I open up the
subform independently. When I open the main form and select the
order from a Combo box to display the order lines (on the subform),
the description turns to #Error.

Frustratingly, I seek advice from my peers. Any thoughts?

Here's the code for the Dlookup:

=DLookUp("Itemname","TblItems","[item]=[forms]![FrmOrdersSubForm]!
[item]")
 
D

Dennis

It works if you open it independently because in that instance it is a form,
but when on the main form it is a subform. Try the refernce like this
=DLookUp("Itemname","TblItems","[item]=Forms![MainForm]![FrmOrdersSubForm].Form.[Item]")
or like this
=DLookUp("Itemname","TblItems","[item]='" &
Forms![MainForm]![FrmOrdersSubForm].Form.[Item] & "'")
 
K

Klatuu

It would be better if you included TblItems in the subform's record source
query. Even with the syntax suggested by Dennis, you will find the
performance of the subform sluggish with a DLookup in it like that.
 

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

Dlookup in subform (Currency) 1
DLookup Function on Subform not working 1
DLookup Method with subform 3
Form/ subform link problems 3
Dlookup prob 3
DLookup in a SubForm 4
Correct use of Dlookup? 3
DLookUp 1

Top