Learn how to a build a cloud-first strategyRegister Now


Passing a parameter to an Access query

Posted on 2005-05-06
Medium Priority
Last Modified: 2010-04-25
I hope this is a very quick question (or a quick 'don't do it that way')

I have an Access db which I'm trying to build a quick web front end to in Dreamweaver.  The db has a query qryUnrecordedHours which required a parameter strStaff (e.g. SmithJ)

When I try to run the query I get error [Microsoft][ODBC Microsoft Access Driver] Too Few Parameters. Expected 1.

How can I pass this value to the query?
Question by:domszanto
LVL 23

Accepted Solution

Saqib Khan earned 1500 total points
ID: 13946485
your are not passing Parameters for that Query

Rs.open "Query_Name 'Smith'", ConnectionObj

if Smith is a Variable Then

MyName = "Smith"
Rs.open "Quert_Name '"& MyName &"'", ConnectiobObj
LVL 54

Expert Comment

by:Ryan Chong
ID: 13950511
or try copy the SQL statement from that Query and directly paste it at your web page there, and that will resolve your problem directly.

Hope this make sense to you, regards

Author Comment

ID: 13958702
Thanks, that basically worked.

For the record, the automatic code Dreamweaver puts in is

Set RecordSet = Server.CreateObject("ADODB.Recordset")
RecordSet.ActiveConnection = MM_WTD_STRING
RecordSet.Source = "SELECT * FROM QueryName"
RecordSet.CursorType = 0
RecordSet.CursorLocation = 2
RecordSet.LockType = 1

so what I did was let it do that and then edit it to

Set RecordSet = Server.CreateObject("ADODB.Recordset")
RecordSet.ActiveConnection = MM_WTD_STRING
RecordSet.CursorType = 0
RecordSet.CursorLocation = 2
RecordSet.LockType = 1
RecordSet.Open("QueryName 'Parameter'")

Which has done the trick.

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question