Question : DLookUp based on text box

I know very little about access.  I am trying to have a text box that users can enter a customer number in and have a second box populated with the customer name.  I will be adding others like address and contact info.  

my text box is Text0

I have 2 linked sql tables
CRD1
OCRD

Fields

CardCode  = customer number
CardName = customer name

i have text0 as unbound text box
then i have CardName box below it

I have tried variations of the following but always get #error or #name

=DLookUp([CardName],[dbo_ocrd]," [dbo_OCRD]![CardCode]  =  [Text0] ")

Answer : DLookUp based on text box

A couple of issues with the DLookup syntax:

- The field you are looking up and the table name both need to appear in quotes.
- The textbox you are using needs to be concatenated to the Where clause.
- Since this is a control source property (not VBA), "Me." is not recognized and should be omitted

Assuming text cardcode:

=DLookUp("CardName", "dbo_ocrd","CardCode = '" & [Text0] & "'")

Assuming numeric:

=DLookUp("CardName", "dbo_ocrd","CardCode = " & [Text0] )

Random Solutions  
 
programming4us programming4us