View Full Version : DLOOKUP help


ocp&mcsd
11-17-2007, 12:46 AM
Dear all,
How are you?
I need your help.
Can you help me in this DLOOKUP function.
I want to retreive "covered period" from financial statement table where investment id = the value of investment ID from Financial statement form.
This is the syntax:
x: DLookUp("[PeriodCovered]","Financial Statements","[InvestmentID] = " & Forms!Investments!InvestmentID)

Kidly,find attached the DB.

Thanks in advance.

boblarson
11-17-2007, 12:53 AM
It works for me. You just have to make sure your form is opened before opening the query. Or, did I miss something. Was that not the question?

ocp&mcsd
11-17-2007, 05:44 AM
Thank you my dear
It also works with me.
It won't work without leaving the form opened??
Why??

boblarson
11-17-2007, 08:45 AM
The WHERE clause of the DLookup says:

[InvestmentID] = " & Forms!Investments!InvestmentID

which is a reference to a field on the form. If the form isn't open, that doesn't exist.

Pat Hartman
11-17-2007, 05:59 PM
Forms don't store data, tables store data. Forms only hold data when they are open. It's like the difference between your hard drive and memory.

ajetrumpet
11-17-2007, 06:27 PM
Thank you my dear
It also works with me.
It won't work without leaving the form opened??
Why??Just to add a bit here, references don't work when the form is not open because of what Pat said. Think of a form as a display tool. If it's not open, it can't display, and if it can't display, there can be no data (holder) to reference. Just a little logic for your brain... :)