Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
| Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 24th, 2004, 09:08 AM
Authorized User
 
Join Date: Jun 2003
Location: Swansea, , United Kingdom.
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error "Too Few Parameters - Expected 1"

Error in the following code:

sql = "INSERT INTO SPCCalculator ( [Value], [Date], [Description] ) "

sql = sql + "SELECT (CDPTL_Activity.CDPTL_DateAdmitted-CDPTL_Activity.CDPTL_DecisionToAdmitDate)/" + CStr(TimeDivider) + " AS [Value], CDPTL_Activity.CDPTL_DateAdmitted as [Date],Description as [Description]"
sql = sql + "FROM CDPTL_Activity "
sql = sql + "where cdptl_procedurecode in "
sql = sql + "(SELECT CodeGroupMembers.[OPCS no dot] "
sql = sql + "FROM CodeGroupMembers INNER JOIN CodeGroupNames ON CodeGroupMembers.CodeGroupID = CodeGroupNames.CodeGroupID "
sql = sql + "where CodeGroupNames.CodeGroupID = "
sql = sql + CStr(cmbOPCS.value)
sql = sql + ")"
sql = sql + " AND CDPTL_Activity.CDPTL_SpecialtySplit Like """
sql = sql + cmbSpecialtySplit.value
sql = sql + """ AND CDPTL_Activity.CDPTL_SpecialtyGroup Like """
sql = sql + cmbSpecialtyGroup.value
sql = sql + """ "
sql = sql + DtRange
sql = sql + IntMgtFilter
sql = sql + "order by cdptl_DateAdmitted ASC;"

DoEvents

db.Execute (sql)

Any ideas.

Many Thanks

Tim
__________________
Tim
 
Old August 25th, 2004, 09:58 PM
rjp rjp is offline
Registered User
 
Join Date: Aug 2004
Location: Perth, WA, Australia.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

its the "AS" in

SELECT fieldname AS value

That is what causes the error you reported.
ie use


SELECT field

in the INSERT part just put the corresponding field names there
ie

INSERT INTO tablename (field1,field2,field3)

I know this because i tried something similar last week.
But then again you might know something i dont.

***********************************
If for some reason that does not work i would debug it by:
1) Printing out the sql to the immediate window
     debug.print sql
2) Run the sql in the immediate window
    
    docmd.runquery(".....")
3) Make alterations to the sql until it works or run individual
     portions of the SQL statement

Note: any quotes (") in your sql have to be altered to (""") or (')

I generally find it best to start off basic so that the sql works and then successively build up the whole sql.
 
Old August 31st, 2004, 04:04 AM
Authorized User
 
Join Date: Jun 2003
Location: Swansea, , United Kingdom.
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Mate,

Will give it a try!!



Tim




Similar Threads
Thread Thread Starter Forum Replies Last Post
too few parameters expected 1 jim11 Access VBA 1 December 7th, 2005 03:41 PM
Too few parameters. 1 expected !!! chacquard Access VBA 2 June 21st, 2005 08:00 AM
too few parameters expected n desprate Access VBA 6 April 29th, 2005 06:33 AM
Error:0x80040E10 -Too few parameters. expected 1 mikest Access ASP 2 December 5th, 2004 10:31 PM
Too few parameters. Expected 1. harry_barry Classic ASP Databases 2 May 26th, 2004 04:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.