Dlookup Subform Problem

  • Thread starter Thread starter DubboPete
  • Start date Start date
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]")
 
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] & "'")
 
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.
 
Back
Top