Solved

Dlookup not working - getting #Name?

Posted on 2013-06-26
12
116 Views
Last Modified: 2014-10-16
Hi.

I'm trying to do a Dlookup in a subform, but pulling some data from the main form:

I'm using the following as a record source:
=DLookUp("Location";"Q_strukturvaretotal";"id_vare"="'" & [vare_id] & "'")

I'm getting #Name! instead of the lookup value. I use [vare_id] to refer to the text field in the main form. What is the correct syntax for correctly refering to a text field in the main form in this instance?
0
Comment
Question by:EvertJor
  • 7
  • 3
  • 2
12 Comments
 
LVL 57

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
You need comma's between the arguments, not semi-colon's and your delimiting on the text value was not correct:

=DLookUp("Location","Q_strukturvaretotal","id_vare='" & [vare_id] & "'")

or more clearly:

=DLookUp("Location","Q_strukturvaretotal","id_vare=" & chr$(34) & [vare_id] & chr$(34))

chr$(34) giving you a quote (") character.

Jim.
0
 
LVL 57

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
BTW, if [vare_ID] is a numeric field, it would be:

=DLookUp("Location","Q_strukturvaretotal","id_vare=" & [vare_id] )

Jim
0
 

Author Comment

by:EvertJor
Comment Utility
I'm getting invalid syntax on both your suggestions.
0
 

Author Comment

by:EvertJor
Comment Utility
This is in a form not in a query. As far as I know I have to use semicolons in this instance (ie. when refering to the Dlookup function as a record source).

Tested by switching to commas - and I get the "syntax error" as described in my last posting.
0
 
LVL 49

Expert Comment

by:Gustav Brock
Comment Utility
Of course you need your localized semicolons. Thus, for a numeric id:

=DLookUp("Location";"Q_strukturvaretotal";"id_vare = " & [vare_id] & "")

or for a string id:

=DLookUp("Location";"Q_strukturvaretotal";"id_vare = '" & [vare_id] & "'")

/gustav
0
 

Author Comment

by:EvertJor
Comment Utility
Still getting the same syntax error cactus_data.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:EvertJor
Comment Utility
Hi.

Now I'm only getting bank values in the Dlookup - but no errors. The values exist in the underlying query.
0
 

Author Comment

by:EvertJor
Comment Utility
Neither Dlookup or Elookup seems to work. See: http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_27991704.html

It just returns empty strings. I'm using Windows8 with the 32 bit version of Access.
0
 
LVL 49

Expert Comment

by:Gustav Brock
Comment Utility
Then either  [vare_id] contains no value (try with =[vare_id]), or you need to rename the textbox of which this is your controlsource.

/gustav
0
 

Accepted Solution

by:
EvertJor earned 0 total points
Comment Utility
Have still not gotten a working solution. Please close this ticket.
0
 
LVL 49

Expert Comment

by:Gustav Brock
Comment Utility
Neither did you for more than a year provide any feedback.

Anyway, if vare_id is on the parent form, you may need this modification:

=DLookUp("Location";"Q_strukturvaretotal";"id_vare = '" & Forms!NameOfTheParentForm![vare_id] & "'")

 /gustav
0
 

Author Closing Comment

by:EvertJor
Comment Utility
I have not received a suggestion that solves the problem.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Ever notice how you can't use a new drive in Windows without having Windows assigning a Disk Signature?  Ever have a signature collision problem (especially with Virtual Machines?)  This article is intended to help you understand what's going on and…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now