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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alternative to DLookup? 1

Status
Not open for further replies.

lastout

Programmer
Apr 12, 2002
84
US
Is there an alternative to DLookup? I seem to remember reading somewhere that DLookup was antiquated and that newer versions of Access have a new way of doing the same thing.

Also, can DLookup's use variables? I have the following but it doesn't work because there is more than one field on the form called ProjectID (same field from two different tables).


=DLookUp("[ProjectName]","tblProject","[ProjectID] = " & " frmAddTenants.ProjectID")
 
A form cannot have two fields with the exact same name!
 
Hi,

First, if you have two fields alike, name the table like:

"[TheTable]![ProjectID]="

Second, use the function Trim() to remove any spaces:

Trim("frmAddTenants.ProjectID")


Jean-Paul
Montreal
jp@solutionsvba.com
mtljp2@sympatico.ca
 
Hi,

One alternative to DLookup is to use a recordset object to return the data that you want. However, it is a lot slower.

Can DLookup use variables? Yes. For example:

=DLookUp("[ProjectName]","tblProject","[ProjectID] = '" & Me!txtProjectID & "'")

If you use the control name rather than the database field name, it will resolve differently for each record as appropriate.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top