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 » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

DLookup Problem



 
 
Thread Tools Display Modes
  #1  
Old May 4th, 2010, 05:15 PM posted to microsoft.public.access
tgavin
external usenet poster
 
Posts: 57
Default DLookup Problem

Here is my code. It is returning a type mismatch error and I can't figure out
why.

dblPriceToPurchase = DLookup("[dblPriceToPurchaseFactor]", "tblPricing",
"[intItem] = " & [intItemID] And "[intVendor] = " & Forms!frmPO![intVendor])

Thanks
Terri
  #2  
Old May 4th, 2010, 05:28 PM posted to microsoft.public.access
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default DLookup Problem

"tgavin" wrote in message
...
Here is my code. It is returning a type mismatch error and I can't figure
out
why.

dblPriceToPurchase = DLookup("[dblPriceToPurchaseFactor]", "tblPricing",
"[intItem] = " & [intItemID] And "[intVendor] = " &
Forms!frmPO![intVendor])



Quotes in the wrong place. Try this:

dblPriceToPurchase = _
DLookup("[dblPriceToPurchaseFactor]", "tblPricing", _
"[intItem] = " & [intItemID] & _
" And [intVendor] = " & Forms!frmPO![intVendor])

By the way, you don't actually need all those square brackets ([]) in this
case.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #3  
Old May 4th, 2010, 05:36 PM posted to microsoft.public.access
fredg
external usenet poster
 
Posts: 4,386
Default DLookup Problem

On Tue, 4 May 2010 09:15:01 -0700, tgavin wrote:

Here is my code. It is returning a type mismatch error and I can't figure out
why.

dblPriceToPurchase = DLookup("[dblPriceToPurchaseFactor]", "tblPricing",
"[intItem] = " & [intItemID] And "[intVendor] = " & Forms!frmPO![intVendor])

Thanks
Terri


regarding: = " & [intItemID] And "[intVendor] = " & Forms!etc..
"And" is not the same as & when writing code.

dblPriceToPurchase = DLookup("[dblPriceToPurchaseFactor]",
"tblPricing", "[intItem] = " & [intItemID] & "And [intVendor] = " &
Forms!frmPO![intVendor])

The above assumes both criteria fields are Number datatypes.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 




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 02:24 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.