Passing a parameter to an Access query

Posted on 2005-05-06
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

    your are not passing Parameters for that Query "Query_Name 'Smith'", ConnectionObj

    if Smith is a Variable Then

    MyName = "Smith" "Quert_Name '"& MyName &"'", ConnectiobObj
    LVL 48

    Expert Comment

    by:Ryan Chong
    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

    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 your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    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…
    This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video discusses moving either the default database or any database to a new volume.

    731 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now