DLookup and form referencing

H Pepper

Registered User.
Local time
Today, 15:16
Joined
Apr 18, 2002
Messages
13
I need to use the dlookup function in a subform and just can't get it to work. I have a patient form (frmPATIENT) and a subform (frmSPECIMEN). I want the discipline name displayed when the user selects the appropriate discipline (Using a toggle button of four)

=DLookUp("[DISCIPLINE_NAME]","tblDISCIPLINE","DISCIPLINE_ID=" & [Forms]![frmPATIENT]![frmSPECIMEN].[Form].[frameDISCIPLINE])

Am I referencing the form correctly? I can get it to work by just using the subform on its own (ie leaving out [frmPATIENT]) but I need to be able to put it all together. I keep getting #name displayed.

Incidentally, if there is no value, I keep getting #error but I would just like to see an empty field. How do I do this?

Your help would be very much appreciated
 
You wrote
<<
=DLookUp("[DISCIPLINE_NAME]","tblDISCIPLINE","DISCIPLINE_ID=" & [Forms]![frmPATIENT]![frmSPECIMEN].[Form].[frameDISCIPLINE])
>>

I believe you want
=DLookUp("[DISCIPLINE_NAME]","tblDISCIPLINE","DISCIPLINE_ID=" & [Forms]![frmPATIENT]![frmSPECIMEN].[Form]![frameDISCIPLINE])
with the bang "!" between Form and frameDISCLIPINE

RichM
 
Just thought I'd update you on the reason why this was not working. Although I'd called my subform "frmSPECIMEN", because it was linked to the patient form, the name given by access automatically is "frmSPECIMENsubform" (can tell this by looking at the properties of the subform from the patient form)


My advise to anyone, check names of objects when referencing them even if you think you are sure you know the name!!!!!
 

Users who are viewing this thread

Back
Top Bottom