text box dlookup error

rsadmin

New member
Local time
Today, 13:53
Joined
Aug 15, 2008
Messages
3
I have an unbound text box, where a user types in a part number, and when he types it in, I want the 2nd text box to populate it based on the first.

My function is:

=DLookUp("[LEGRISPN]","[tblSMCParts]","[SMCPN]=" & [fldtxtsmc])

when I show the form in form mode, it comes back as #Error.

I am using Access 2007.

I appreciate any help
 
=DLookUp("[LEGRISPN]","[tblSMCParts]","[SMCPN]=" & [fldtxtsmc])
I don't know about Access 2007 but...

Your table name should not be enclosed in [].

Your form field needs to be wrapped in quotes because it is a text field

So your expression should look like this:
DLookUp("[LEGRISPN]","tblSMCParts","[SMCPN]=" & "'" & [fldtxtsmc] & "'" )

The concatenation can be simplified but I've presented it in full so you can hopefully see the single quotes

hth
Chris
 
Last edited:
The concatenation can be simplified but I've presented it in full so you can hopefully see the single quotes

Actually, whether the Criteria clause needs the quotation marks or not depends on whether [SMCPN] is defined as Text or Numeric Datatype, which hasn't been established.

Having said that, things like parts "numbers" really shouldn't be Numeric, but rather Text. Data containing all digits should only be defined as Numeric if it will be used in math calculations.
 
Actually, whether the Criteria clause needs the quotation marks or not depends on whether [SMCPN] is defined as Text or Numeric Datatype, which hasn't been established.
Good point, bad assumption by me.
Chris
 

Users who are viewing this thread

Back
Top Bottom