Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLookup Function Problem

Status
Not open for further replies.

FontanaS

Programmer
May 1, 2001
357
US
Hello,

I am using the following function in a form:

DLookup("[awardstatus]", "tbl_award_Status", [Forms]![Frm_Center_Summary_Grant_Totals].[awardwordvariable])

The error I am getting is ?Name.

all of the variables are correct. in the where part ([Forms]![Frm_Center_Summary_Grant_Totals].[awardwordvariable]) I am assigning it in the open event of the form this -

awardwordvariable = "[awardstatuscode] = '" & strcenterchoice & "'"

strcenterchoice might be 'CAW','CNE',etc. For testing I am using 'CNE'.

any suggestions would be greatly appreciated
 
Did you try the DLookup with "!" instead of a period before [awardwordvariable]?

Or, if strcenterchoice in

awardwordvariable = "[awardstatuscode] = '" & strcenterchoice & "'"

isn't TEXT, you should remove the single quotes

awardwordvariable = "[awardstatuscode] = " & strcenterchoice

Hope this helps.

Jim DeGeorge [wavey]
 
[Forms]![Frm_Center_Summary_Grant_Totals].[awardwordvariable])

Put the criteria section of the dlookup function above in quotes as you did with the domain or table name.
 
Your criteria is not set up right:
DLookup("[awardstatus]", "tbl_award_Status", "[awardstatus]=" & [Forms]![Frm_Center_Summary_Grant_Totals].[awardwordvariable])

if [awardstatus] is numeric or:

DLookup("[awardstatus]", "tbl_award_Status", "[awardstatus]='" & [Forms]![Frm_Center_Summary_Grant_Totals].[awardwordvariable] & "'")

if not.

hth

Ben

----------------------------------------------
Ben O'Hara

"Where are all the stupid people from...
...And how'd they get so dumb?"
NoFX-The Decline
----------------------------------------------
 
Ben

In my response, I was hung up on the TEXT versus NUMBER issue that I didn't see that Fontana didn't even have the DLookup syntax right! Good catch!

Jim DeGeorge [wavey]
 
Actually, bad catch.
Just reread the problem and the syntax is more right than I thought. It's the way the variable is being called that's the problem.
At the beginning the variable awardwordvariable is set:

awardwordvariable = "[awardstatuscode] = '" & strcenterchoice & "'"

it's just not being called properly. I gues you are using this in a calculated control on your form. Your record source should look like:
=DLookup("[awardstatus]", "tbl_award_Status", [Forms]![Frm_Center_Summary_Grant_Totals].[awardwordvariable])


Cheers

B

----------------------------------------------
Ben O'Hara

"Where are all the stupid people from...
...And how'd they get so dumb?"
NoFX-The Decline
----------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top