A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Help with dlookup please.



 
 
Thread Tools Display Modes
  #1  
Old January 4th, 2010, 01:45 PM posted to microsoft.public.access.forms
FatMan
external usenet poster
 
Posts: 35
Default Help with dlookup please.

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
  #2  
Old January 4th, 2010, 02:01 PM posted to microsoft.public.access.forms
NG
external usenet poster
 
Posts: 56
Default Help with dlookup please.

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

"FatMan" wrote:

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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:49 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.