Help with dlookup please.

  • Thread starter Thread starter FatMan
  • Start date Start date
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
 
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
 
Back
Top