Re: Query from a list



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.








.



Relevant Pages

  • Re: CREATE VIEW error
    ... exists, yes the query works in access development, asking more is time ... Is Field3 really your field name? ... The EXECUTE accepts an execute query which will be used with a ... The idea is that i need to write me complex queries, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: CREATE VIEW error
    ... exists, yes the query works in access development, asking more is time ... Is Field3 really your field name? ... The EXECUTE accepts an execute query which will be used with a ... The idea is that i need to write me complex queries, ...
    (microsoft.public.dotnet.framework.adonet)
  • SQL Injection
    ... I am currently pen-testing a web app and I am stuck in trying to execute two queries sequentially in Oracle. ... To my knowledge I can do this in SQL by separating the two queries with; however this is no happening in my case in two circumstances... ... I have a discovered an injectable sql query that is fed its data from a web form, the end query build by a cgi-script being ... This list is provided by the SecurityFocus Security Intelligence Alert ...
    (Pen-Test)
  • Re: Strange problem?
    ... > I'm not sure if it's related with your problem but i had similar problem before, same query is working great when i execute it on my qa but when the application executes it,it timeouts. ... >>on the server looked normal (memory, services, cpu, connections, queries). ...
    (microsoft.public.sqlserver.server)
  • Re: Query from a list
    ... 'get a list of all queries for the given groupid ... Set rec = qry.OpenRecordset ... 'grab the appropriate query with name of in the QueryName field ... Set qry = CurrentDb.QueryDefs) ...
    (microsoft.public.access.gettingstarted)

Loading