Solved

Dlookup not working - getting #Name?

Posted on 2013-06-26
12
121 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
ID: 39279280
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
ID: 39279290
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
ID: 39279385
I'm getting invalid syntax on both your suggestions.
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 

Author Comment

by:EvertJor
ID: 39279402
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 50

Expert Comment

by:Gustav Brock
ID: 39279611
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
ID: 39279844
Still getting the same syntax error cactus_data.
0
 

Author Comment

by:EvertJor
ID: 39280214
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
ID: 39280226
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 50

Expert Comment

by:Gustav Brock
ID: 39280444
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
ID: 40374940
Have still not gotten a working solution. Please close this ticket.
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 40374945
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
ID: 40383883
I have not received a suggestion that solves the problem.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

679 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