Help with dlookup please.

F

FatMan

Can someone please help me determine what is wrong with the following code:

Me.txtPalletNo = DLookup("[PalletBarcode]", "[dbo_StockLog]",
"[BoxBarcode]=" & [Forms]![frmTraceBox]!txtBoxCode)

Where...
PalletBarcode is the value I want to retrieve.

dbo_StockLog is the table in the data is stored in. This table is a linked
table from an SQL server. I can open, add/delete data to the table, use it
in querries, etc.

BoxBarcode that I need to match from my form (frmTraceBox)

txtBoxCode is the control on my form that contains the value I am trying to
match in the table.

When I run my code I get the following error....

The expression you entered as a query parameter produced this error:
The object dosen't contain the Automation object "B9HHE1137390518"

I know the value B9HHE1137390518 is a valid BoxBarcode as I have copied and
pasted (as well as typed it in) the value directly from the table to the form
for testing my code.

Can anyone please tell me what I am doing wrong? All help is greatly
appreciated.

Thanks,
FatMan
 
N

NG

Hi,

as the boxcode is a text it should be transmitted between parenthesis. To
send a " char you have to double it in code,

so try

Me.txtPalletNo = DLookup("[PalletBarcode]", "[dbo_StockLog]",
"[BoxBarcode]= """ & [Forms]![frmTraceBox]!txtBoxCode) & """"

greetings
NG
 

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

Top