Re: Query from a list
- From: "DavPet" <dl.peterson@xxxxxxxxxxx>
- Date: Thu, 5 Apr 2007 22:18:15 -0400
Now I get it. It works great for action queries but won't execute a "Select
query".
Cannot execute a select query. (Error 3065)
You tried to use the Execute method with a select query. The Execute method
is valid only with action queries. Select queries contain a SELECT statement
and can return records; action queries do not.
Any ideas??
"hmadyson" <hmadyson@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:BE67C514-3C16-471C-B3A6-D25CB4106D82@xxxxxxxxxxxxxxxx
It depends on what you put in the line strQuery = "Select * from
[query_list]
where group_id=" & GroupID
query_list should be the name of the table that you are looking for.
group_id must be the name of the field that you want to limit on, and
GroupID
must be an appropriate value. If group_id is a text field, you will need
to
change it like
strQuery = "Select * from [query_list] where group_id='" & GroupID &"'"
the previous code assumes that it is a number.
I have proved on my PC that this code works (reason for all of the
rewrites), but it all depends on your database specifics.
"DavPet" wrote:
Thanks for the self-checking and updates.
When I execute "RunQueries (1)"
I am getting this error:
Too few parameters. Expected 1 (Error 3061) at the line that says Set
rec =
qry.OpenRecordset()
Dunno' what to do.
"hmadyson" <hmadyson@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:FD2FDB4B-C17B-43CF-807F-75CBB2320DCD@xxxxxxxxxxxxxxxx
I am so embarassed I made another mistake. Here is the new code
Sub RunQueries(GroupID As Long)
Dim strQuery As String
Dim qry As QueryDef
Dim rec As Recordset
'get a list of all queries for the given groupid
strQuery = "Select * from [query_list] where group_id=" & GroupID
Set qry = CurrentDb.CreateQueryDef("", strQuery)
Set rec = qry.OpenRecordset()
'record list of all of the queries
With rec
'go through the list until it is complete
Do Until (.EOF)
'grab the appropriate query with name of in the QueryName
field
Set qry = CurrentDb.QueryDefs(.Fields("QueryName"))
'run the query
qry.Execute
'move to the next query
.MoveNext
Loop
End With
'clean up by setting objects to nothing
Set qry = Nothing
Set rec = Nothing
End Sub
"DavPet" wrote:
I have a lot of queires.
I want to put the query names in a table, one field of the table will
have a
group_id. Then I want to execute the queries for a certain group_id.
Please jump start me on how to do it.
.
- Follow-Ups:
- Re: Query from a list
- From: hmadyson
- Re: Query from a list
- References:
- Query from a list
- From: DavPet
- Re: Query from a list
- From: DavPet
- Re: Query from a list
- From: hmadyson
- Query from a list
- Prev by Date: Re: Bruce M
- Next by Date: Re: Upgrading to Access 2007
- Previous by thread: Re: Query from a list
- Next by thread: Re: Query from a list
- Index(es):
Relevant Pages
|
Loading