Save SQL to An Existing Query?

SamDeMan

Registered User.
Local time
Today, 14:05
Joined
Aug 22, 2005
Messages
182
Hi

Can i save an SQL statement to an existing Query. what i would like to do is have a crosstab on fields that will be determined at runtime. so i would have the pivot on a field that is chosen at runtime. I can run a sub that will generate the correct SQL, i am just lost on how to save it to an existing query.

the full blown explanation of what i am try to do, is the following. i have a report which is going to use a cross tab. so i need to attach a query to the report. if i assign report.recordsource = SQL i get a message that a crosstab can't be attached to the report. but if i use a saved crosstab and i write report.recordsource = me.myCrosstabQry then it works. don't know why, but it does.

thanks in advance for your help,

sam
 
currentdb.querydefs("QueryName").sql = "Select ... from .. jada jada"

Will put the sql into the query...

Good Luck
 
thanx.
this is for DAO i was looking for the ADO equivelent. apparently, it must be done with ADOX and i found a whole disclosure on MSDN that basically states that this query would be hidden from attaching it to a report. i didn't try this whole thing, but i hope to do it next week, if anybody wants to know the results of my research plz lemme know. in the meantime, check out this link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/adocreateq.asp

credits to Ron Weiner on google groups.


sam
 
this is for DAO i was looking for the ADO equivelent.
CurrentDb.QueryDefs exists in ADO.

(I'm using Access 2K.)

^
 
Last edited:
I use the DAO without any problems and can use the queries in queries and reports without problems....
 

Users who are viewing this thread

Back
Top Bottom