Dlookup Function

G

Guest

I need to know how to do a search using a TEXT field while using the DLOOKUP
function. I want to pull up some additional information based on a project
number. In this case the following is how it is setup:

=DLookUp("[prjName]","tblProj","[pmProjNumber] = [prjNumberHouse]")

The above works if the [pmProjNumber] and [prjNumberHouse] are actually
numbers. In this case, they are actually text strings of the form
"W-0000-000-00" where the "0" is an integer. the [pmProjNumber] comes from a
combo box where the user selects it. [prjName] is a text string and is being
dropped into a textbox.

I keep getting the following message: "#Name?"
 
K

Ken Snell [MVP]

Delimit the text string from the combo box with ' characters:

=DLookUp("[prjName]","tblProj","[prjNumberHouse]='" & [pmProjNumber] & "'")
 
F

fredg

I need to know how to do a search using a TEXT field while using the DLOOKUP
function. I want to pull up some additional information based on a project
number. In this case the following is how it is setup:

=DLookUp("[prjName]","tblProj","[pmProjNumber] = [prjNumberHouse]")

The above works if the [pmProjNumber] and [prjNumberHouse] are actually
numbers. In this case, they are actually text strings of the form
"W-0000-000-00" where the "0" is an integer. the [pmProjNumber] comes from a
combo box where the user selects it. [prjName] is a text string and is being
dropped into a textbox.

I keep getting the following message: "#Name?"


If prjNumberHouse is the name of a control on your form....

If pmProjNumber is text:
=DLookUp("[prjName]","tblProj","[pmProjNumber] = '" & [prjNumberHouse]
& "'")

If pmProjNumber is Number:
=DLookUp("[prjName]","tblProj","[pmProjNumber] = " & [prjNumberHouse])

In VBA help, look up
Restrict data to a subset of records
for how to write the where clause for number and text datatypes.
 
F

fredg

I need to know how to do a search using a TEXT field while using the DLOOKUP
function. I want to pull up some additional information based on a project
number. In this case the following is how it is setup:

=DLookUp("[prjName]","tblProj","[pmProjNumber] = [prjNumberHouse]")

The above works if the [pmProjNumber] and [prjNumberHouse] are actually
numbers. In this case, they are actually text strings of the form
"W-0000-000-00" where the "0" is an integer. the [pmProjNumber] comes from a
combo box where the user selects it. [prjName] is a text string and is being
dropped into a textbox.

I keep getting the following message: "#Name?"

If prjNumberHouse is the name of a control on your form....

If pmProjNumber is text:
=DLookUp("[prjName]","tblProj","[pmProjNumber] = '" & [prjNumberHouse]
& "'")

If pmProjNumber is Number:
=DLookUp("[prjName]","tblProj","[pmProjNumber] = " & [prjNumberHouse])

In VBA help, look up
Restrict data to a subset of records
for how to write the where clause for number and text datatypes.

I forgot to add... Make sure the name of this control is not the same
as the name of any field used in the expression.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Dlookup help Please !! 1
Dlookup is broken... 1
DLookup Function 2
DLookUp error 2
DLookUp Returning Primary Key 4
Trouble with DLookup 3
Add to text box String 4
DLookup in Text box to show Currency (number field) 9

Top