DLookUp - Sub form

  • Thread starter Thread starter jer
  • Start date Start date
J

jer

I have a form frmConfirmationDetails with the below
control which works

=DLookUp("Category","tblCategory","CategoryId=Forms!
[frmConfirmationDetails]!CategoryId")

I have included frmConfirmtionDetails as
a sub-form in frmRequest. I am getting an error with the
dlookup functon. I have looked at the help files and
come up with

=DLookUp("Category","tblCategory","CategoryId=Forms!
frmRequest!Confirmation Details.Form!CategoryId")

where "Confirmation Details" is the name for the
frmConfirmationDetails control in the frmRequest. But I
am still getting an error
Could anybody say what is wrong with this
TIA
jer
 
Hi,

the error came from the 'WHERE' part of dlookup ("CategoryID=Forms!
frmRequest!Confirmation Details.Form!CategoryId"). What you want is to supply the value not the name of the control. Try this one:
if CategoryId is numeric:
=DLookUp("Category","tblCategory","CategoryId=" & Forms!frmRequest!Confirmation Details.Form!CategoryId)

if CategoryID is string/text:
=DLookUp("Category","tblCategory","CategoryId='" & Forms!frmRequest!Confirmation Details.Form!CategoryId & "'")

HTH

----- jer wrote: -----

I have a form frmConfirmationDetails with the below
control which works

=DLookUp("Category","tblCategory","CategoryId=Forms!
[frmConfirmationDetails]!CategoryId")

I have included frmConfirmtionDetails as
a sub-form in frmRequest. I am getting an error with the
dlookup functon. I have looked at the help files and
come up with

=DLookUp("Category","tblCategory","CategoryId=Forms!
frmRequest!Confirmation Details.Form!CategoryId")

where "Confirmation Details" is the name for the
frmConfirmationDetails control in the frmRequest. But I
am still getting an error
Could anybody say what is wrong with this
TIA
jer
 
Trias, thanks much
jer
-----Original Message-----
Hi,

the error came from the 'WHERE' part of dlookup ("CategoryID=Forms!
frmRequest!Confirmation Details.Form!CategoryId").
What you want is to supply the value not the name of the
control. Try this one:
if CategoryId is numeric:
=DLookUp("Category","tblCategory","CategoryId=" & Forms!
frmRequest!Confirmation Details.Form!CategoryId)
if CategoryID is string/text:
=DLookUp("Category","tblCategory","CategoryId='" & Forms!
frmRequest!Confirmation Details.Form!CategoryId & "'")
HTH

----- jer wrote: -----

I have a form frmConfirmationDetails with the below
control which works

=DLookUp("Category","tblCategory","CategoryId=Forms!
[frmConfirmationDetails]!CategoryId")

I have included frmConfirmtionDetails as
a sub-form in frmRequest. I am getting an error with the
dlookup functon. I have looked at the help files and
come up with

=DLookUp("Category","tblCategory","CategoryId=Forms!
frmRequest!Confirmation Details.Form!CategoryId")

where "Confirmation Details" is the name for the
frmConfirmationDetails control in the frmRequest. But I
am still getting an error
Could anybody say what is wrong with this
TIA
jer

.
 
Back
Top