DLookUp Stressed Out

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Okay I used this function many times and it works every other place but this
one path will not work...

Main table is = TblEmployess [TEEmployeeID] [TELastName]

Table receiving information is = TblLogInSheet [TblEmployeeID] "I should
have named it [TEEmployeeID]

Now I want to look the last name up when I enter the Employee ID I tried
=DLookUp("[TblEmployeeID]","[TblLogInSheet]","[TEEmployeeID]=" & [TELastName])

It does not work.......HELP PLEASE........

Thanks
 
Jen said:
Okay I used this function many times and it works every other place
but this one path will not work...

Main table is = TblEmployess [TEEmployeeID] [TELastName]

Table receiving information is = TblLogInSheet [TblEmployeeID] "I
should
have named it [TEEmployeeID]

Now I want to look the last name up when I enter the Employee ID I
tried =DLookUp("[TblEmployeeID]","[TblLogInSheet]","[TEEmployeeID]="
& [TELastName])

You seem to be asking for records where TEEmployeeID, which I would
guess doesn't contain names, is equal to an employee's last name. Also,
your DLookup expression is looking up an EmployeeID given a last name,
but that's not what you said you wanted; you said you want to look up a
last name, given an Employee ID. If what you said is what you want,
then this would be more like it:

=DLookUp("TELastName","TblEmployees",
"TEEmployeeID=" & [TblEmployeeID])

That says, "look in TblEmployees for the record that has TEEmployeeID
equal to [TblEmployeeID], and return the value of TELastName for that
record. Is that what you want?
 
You say you want to look up the last name, however the DLookUp seems to be
looking up the field [TblEmployeeID] from table [TblLogInSheet] for
[TEEmployeeID] = [TELastName].

I think you should be coding along the lines of:
=DLookUp("[TELastName]","[TblEmployess]","[TEEmployeeID]=" & [Employee ID])
Where [Employee ID] is the field you entered and want to look up.

Note that if [TEEmployeeID] is as text field (as opposed to a number) you
should use:
=DLookUp("[TELastName]","[TblEmployess]","[TEEmployeeID]='" & [Employee ID]
& "'")

Note the single quotes around [Employee ID].

Hope this helps.
 
I think it should be:

=Dlookup(“TblEmployeeIDâ€, “TblEmployeesâ€, “TEEmployeeID=TblEmployeeIDâ€)
 
Okay now when I type in either of your formats I get the following error

#name?

istead of just the #error.....


Andrew Tapp said:
You say you want to look up the last name, however the DLookUp seems to be
looking up the field [TblEmployeeID] from table [TblLogInSheet] for
[TEEmployeeID] = [TELastName].

I think you should be coding along the lines of:
=DLookUp("[TELastName]","[TblEmployess]","[TEEmployeeID]=" & [Employee ID])
Where [Employee ID] is the field you entered and want to look up.

Note that if [TEEmployeeID] is as text field (as opposed to a number) you
should use:
=DLookUp("[TELastName]","[TblEmployess]","[TEEmployeeID]='" & [Employee ID]
& "'")

Note the single quotes around [Employee ID].

Hope this helps.

Jen said:
Okay I used this function many times and it works every other place but this
one path will not work...

Main table is = TblEmployess [TEEmployeeID] [TELastName]

Table receiving information is = TblLogInSheet [TblEmployeeID] "I should
have named it [TEEmployeeID]

Now I want to look the last name up when I enter the Employee ID I tried
=DLookUp("[TblEmployeeID]","[TblLogInSheet]","[TEEmployeeID]=" & [TELastName])

It does not work.......HELP PLEASE........

Thanks
 
Jen said:
Okay now when I type in either of your formats I get the following
error

#name?

istead of just the #error.....

Where is the DLookup expression being placed? In the ControlSource of a
text box on a form? That text box must not have the same name as any
field in the form's recordsource. If it does, rename the text box,
maybe by prefixing the name with "txt".

Another possible source of this error: you're getting the ID value to
lookup from some other control on the form. In my example, I guessed
the name of that control was "TblEmployeeID". Is that the actual name
of the control on your form? If not, replace "TblEmployeeID" in the
DLookup expression with the correct name of the control.
 
This is exactly what I want but when I put the code in it returns with:

#error....

That says, "look in TblEmployees for the record that has TEEmployeeID
equal to [TblEmployeeID], and return the value of TELastName for that
record. Is that what you want?

Dirk Goldgar said:
Jen said:
Okay I used this function many times and it works every other place
but this one path will not work...

Main table is = TblEmployess [TEEmployeeID] [TELastName]

Table receiving information is = TblLogInSheet [TblEmployeeID] "I
should
have named it [TEEmployeeID]

Now I want to look the last name up when I enter the Employee ID I
tried =DLookUp("[TblEmployeeID]","[TblLogInSheet]","[TEEmployeeID]="
& [TELastName])

You seem to be asking for records where TEEmployeeID, which I would
guess doesn't contain names, is equal to an employee's last name. Also,
your DLookup expression is looking up an EmployeeID given a last name,
but that's not what you said you wanted; you said you want to look up a
last name, given an Employee ID. If what you said is what you want,
then this would be more like it:

=DLookUp("TELastName","TblEmployees",
"TEEmployeeID=" & [TblEmployeeID])

That says, "look in TblEmployees for the record that has TEEmployeeID
equal to [TblEmployeeID], and return the value of TELastName for that
record. Is that what you want?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top