Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / January 2008

Tip: Looking for answers? Try searching our database.

Frustrating Error when opening a query in VBA code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Dumay - 21 Jan 2008 20:41 GMT
Hi All,

Whenever I want to create a recordset in code using a query that uses a
filter by form variable to refine the data set (or even one that is a
sub-query) i keep getting the following erro when the code tries to create
the recordset.

"Run Time Error '3601' Too Few Parameters Epected 1"

Can someone explain why I get this error and what to do about it? The
frustrating thing is that the query runs perfectly when I design it but not
when I call it in code.

As always any help is really appreciated.

Regards,

john Dumay
Krzysztof Pozorek [MVP] - 21 Jan 2008 20:53 GMT
> Hi All,
>
[quoted text clipped - 9 lines]
> not
> when I call it in code.

You have to list the parameters of query. Modify Your code to something like
this:

Dim q As QueryDef, p As Parameter, rs As Recordset
   Set q = CurrentDb.QueryDefs("QueryParam")
   For Each p In q.Parameters
       p.Value = Eval(p.Name)
   Next
   Set rs = q.OpenRecordset()
   '(...) any recordset operations
   Set rs = Nothing
   Set q = Nothing

K.P. MVP, Poland
www.access.vis.pl
John Dumay - 21 Jan 2008 21:17 GMT
Hi Krzysztof,

Man what a relief, that worked perfectly.

many thanks for your assistance!

Regards,

John Dumay

> > Hi All,
> >
[quoted text clipped - 25 lines]
> K.P. MVP, Poland
> www.access.vis.pl 
Tom van Stiphout - 22 Jan 2008 03:49 GMT
Elegant!

-Tom.

<clip>

>You have to list the parameters of query. Modify Your code to something like
>this:
[quoted text clipped - 11 lines]
>K.P. MVP, Poland
>www.access.vis.pl
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.