?
Solved

dlookup returns wrong entry

Posted on 2011-03-24
6
Medium Priority
?
470 Views
Last Modified: 2012-05-11
I have a small database and, in a form, I do need to obtain a value in a table that dependes on the combination of  2 entries.
I am using the Dlookup funcion as per below:

=DLookUp("[EstabelecimentoBancario]";"[ContaBanco]";"[NumeroProjeto]='" & [FormCodigoProjetoFED] & "'" And "[NomeBeneficiario]='" & [FormNomeBeneficiario] & "'")

and I am using this for 3 fields in the form as I need to obtain 3 different values.
However, in the form, I am consistently getting , for the first field, a wrong return, and for the other, it is returing "#error"
I am attaching the database

can anyone help me?  formulariosFEDON.accdb
0
Comment
Question by:João serras-pereira
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 35206237
try this


=DLookUp("[EstabelecimentoBancario]";"[ContaBanco]";"[NumeroProjeto]='" & [FormCodigoProjetoFED] & "' And [NomeBeneficiario]='" & [FormNomeBeneficiario] & "'")

where did you place the codes that you are using?

are these the names of the controls in the form?

[FormCodigoProjetoFED],  [FormNomeBeneficiario]

what is the name of the form?
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 35206245
>>Zones: MS SQL Server, Microsoft Applications, Microsoft Access Database<<
This has nothing to do with SQL Server.  Please request that the MS SQL Server zone be removed.
0
 
LVL 58
ID: 35206254
Without looking at the DB:

1. You need to use coma's as delimiters between the arguments, not semi-colons:

=DLookUp("EstabelecimentoBancario","ContaBanco","[NumeroProjeto]='" & [FormCodigoProjetoFED] & "'" And "[NomeBeneficiario]='" & [FormNomeBeneficiario] & "'")

2. and this:

[FormCodigoProjetoFED]

  Does not look right.  If this is in code in a form, it should be in the format of:

  Me.<myControlName>

 So it might look like this:

=DLookUp("EstabelecimentoBancario","ContaBanco","[NumeroProjeto]='" & Me.ProjetoFED & "'" And "[NomeBeneficiario]='" & Me.Beneficiario] & "'")

 Where ProjetoFED and Beneficiario would be the control names.

  Ifthe Dlookup statement is being used as the controlsource of a control, then it should be in the format of:

 Forms![<myControlName>]

=DLookUp("EstabelecimentoBancario","ContaBanco","[NumeroProjeto]='" & Forms![FormCodigo]![ProjetoFED] & "'" And "[NomeBeneficiario]='" & Forms![FormCodigo]![Beneficiario] & "'")

JimD.

0
 

Author Closing Comment

by:João serras-pereira
ID: 35207835
it worked perfetly thanks!
0
 

Author Comment

by:João serras-pereira
ID: 35207872
Just a final note:

JDettman: thanks for removing for me; I ha wrongly classified it

also commas are not delimiters in my system. I can't tell why but the delimiters are semi-colons in Portugal althou my system is in english..
acperkinds: thanks for the alert



0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Suggested Courses

764 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