Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access ASP
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access ASP Using ASP with Microsoft Access databases. For Access questions not specific to ASP, please use the Access forum. For more ASP forums, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access ASP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old November 15th, 2006, 09:27 AM
Registered User
Join Date: Nov 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem running SQL query on Access

Hi I am trying to convert my website from SQL to MS Access so that I can keep a functional backup in Access.

On this page, I am getting the following error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Wrong number of arguments used with function in query expression 'isnull(tradeprice,UnitPrice)'.

This is the coresponding area of code producing the error. (All code works perfectly in SQL, but gives this error in Access)

Dim rsSpecial
Dim mstrSql
Dim rsSpecial_numRows
mstrSql = "SELECT ProductID, SubCatagoryID, ProductName, ProductPict, SpecialPrice,"
     if isTradeAccount then
        mstrSql = mstrSql & "isnull(tradeprice,UnitPrice)"
        mstrSql = mstrSql & "UnitPrice"
     end if

  mstrSql = mstrSql & " as UnitPrice, 0 as ProductDetailID FROM Products WHERE Special = 'Yes' and ProductID not in (select ProductID from ProductDetails) union " & _
   "SELECT po.ProductID, po.SubCatagoryID, po.ProductName,pr.Pict as ProductPict, " & _
     "isnull(pr.SpecialPrice,po.SpecialPrice) as SpecialPrice,"
     if isTradeAccount then
        mstrSql = mstrSql & "isnull(pr.tradeprice,pr.UnitPrice)"
        mstrSql = mstrSql & "pr.UnitPrice"
     end if
     mstrSql = mstrSql & " as UnitPrice,pr.ProductDetailID FROM Products po inner join productDetails pr on po.ProductID=pr.ProductID WHERE pr.onSpecial = 'Yes' order by ProductDetailID, SubCatagoryID DESC"

Set rsSpecial = Server.CreateObject("ADODB.Recordset")
rsSpecial.ActiveConnection = MM_connTS_STRING
rsSpecial.Source = mstrSql
rsSpecial.CursorType = 0
rsSpecial.CursorLocation = 2
rsSpecial.LockType = 1

rsSpecial_numRows = 0

What should I change to get this to work?
Thanks for you help in advance,

Reply With Quote
  #2 (permalink)  
Old November 26th, 2006, 05:09 PM
Friend of Wrox
Join Date: Jun 2003
Location: Melbourne, Vic, Australia.
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts

The problem is that ISNULL functions differently in Access.
In Access, IsNull returns True or False for ONE parameter.
I'd suggest using IIF (check Access Help) with something like:
mstrSql = "SELECT ProductID, SubCatagoryID, ProductName, ProductPict, SpecialPrice,"
     if isTradeAccount then
        mstrSql = mstrSql & "iif(tradeprice is null, UnitPrice, tradeprice)"
        mstrSql = mstrSql & "UnitPrice"
     end if

I am a loud man with a very large hat. This means I am in charge
Reply With Quote

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Running an Access Query from ASP arholly Access ASP 0 January 25th, 2008 02:31 PM
SQL query problem in Access - Urgent Kaustav Access 2 September 30th, 2005 11:39 PM
SQL query question in Access dlamarche Access 3 April 3rd, 2005 10:42 PM
problem running ms access application method Access 1 March 23rd, 2005 08:16 AM
Running an SQL query in VBA... Augusta Access VBA 3 December 1st, 2004 04:17 AM

All times are GMT -4. The time now is 01:39 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.