Dlookup code

  • Thread starter Afrosheen via AccessMonster.com
  • Start date
A

Afrosheen via AccessMonster.com

Here's my code:

DLookup("[supervisor]", "tblsupervisor", "[supervisor]= " & NewData)

Here's what I'm trying to do still. I have a field called [Supervisor] in a
table called tblsupervisor. The NewData is a string that you type in. I keep
on getting the error compile error. expected a = sign. So that means that
it's not going to find the record.

Thanks for reading this.
 
D

David H

DLookup is a function that returns a value and thus must be assigned to a
variable or placed in to an expression as in...

strSupervisorName = DLookup([.......])

if DLookup([...]) = "Test" then...

Also, if NewData contains a string value, you should encapsulate it in
single apostrophes as in DLookup("[supervisor]", "tblsupervisor",
"[supervisor]= " & "'" & NewData & "'")

Keep in mind that if NewData has a single apostrophe in it itself it might
crap things up.
 
J

John W. Vinson

Here's my code:

DLookup("[supervisor]", "tblsupervisor", "[supervisor]= " & NewData)

Here's what I'm trying to do still. I have a field called [Supervisor] in a
table called tblsupervisor. The NewData is a string that you type in. I keep
on getting the error compile error. expected a = sign. So that means that
it's not going to find the record.

Thanks for reading this.

That's not the code - just a little chunk of it. And it's not at all clear
what you want the code to do! If the user type in Jones, and if you put the
needed quotemarks around Newdata, this would return Jones if there were such a
record in tblSupervisor; otherwise it would return Null.

What's the context?
 
A

Afrosheen via AccessMonster.com

Hi again John,
The newdata is for a text box like: Tom. Then it supposed to go to the
supervisor file and look up tom and display the information for Tom for
editing
Here's my code:
[quoted text clipped - 6 lines]
Thanks for reading this.

That's not the code - just a little chunk of it. And it's not at all clear
what you want the code to do! If the user type in Jones, and if you put the
needed quotemarks around Newdata, this would return Jones if there were such a
record in tblSupervisor; otherwise it would return Null.

What's the context?
 
J

John W. Vinson

Hi again John,
The newdata is for a text box like: Tom. Then it supposed to go to the
supervisor file and look up tom and display the information for Tom for
editing

But the code you posted will not do so. It will take "Tom" as the input and
return "Tom" as the output. DLookUp simply will not help for what you want to
do.

I'll reply in your other thread.
 

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

Need help with this code 2
Another Not in List not working 11
Report Group Footer DLookUp 0
Dlookup Problem 3
Finding First then Next 5
Something wrong with dlookup? 5
dlookup 2
Two types of errors in SQL statement 2

Top