Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is it possible to do a select from a query???

Status
Not open for further replies.

crowsario

Programmer
Jul 23, 2001
24
US
Hello argPerson,

I am trying to do a select statement from an Access Query.
I don't really want to have to do to an "access.docmd.openQuery" statement. Is it at all possible to do something like:

str_sql="select * from [Query1]", so i can set an array = to the records returned from that array?

Thanks in advance
-Crow
 
You might consider taking the SQL from the Access query and paste it into the VB str_sql variable. That way you don't have to depend on that query always being there and it gives you a little more control.

I'm not sure about the answer to your question but maybe this will help.
RKA:)
 
I was thinking about doing this but the here is my dilemma. The where clause may have to change from time to time and i do not want to have to make a change to the front end. I would rather do this from the backend. Do you know of anyway to copy the sql statement stored in the query programatically?

many thanks
-crow
 
It appeared to me from what I tried that you could use a query name interchangably with a table name. It seemed to look at them exactly the same. I would try putting in the query name, such as "Select * From Query" just like it was a table. It seemed to work in Access and VB. Hope it works.
RKA:)
 
It didn't work for me when i referenced a Union Query, so i tried a different query...and you're right. It does allow this type of select statement on a query, however it is still throwing a "too few parameters error" when that query is a Union Query.

Any thoughts?
-crow
 
I figured out what the problem is.... the error occurs when I use &s and "s in an access query (which is fine for use in access) but not when i'm trying to do a select from it.
Thanks anyway RAtkison
-Crow
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top