I am using Access 2000, but my manual is for Access 2003. In 2003 you
can declare databases and querydefs as follows:
dim qdf as QueryDef
dim dbs as Database
but this doesn't seem to work in 2000. At least, I couldn't make it
work. I managed to create a new querydef, though, using the following
code:
Set querydef = CurrentDb.CreateQueryDef(qdefName, strSQL)
Question 1: is there a way to get the database name and store it as a
variable, so that the code would read:
dim dbs as Database
Set querydef = dbs.CreateQueryDef(qdefName, strSQL)
Question 2: If I create an alternate SQL string, what is the code to
identify the appropriate queryDef and replace the SQL string with the
alternate. Again, the 2003 example I have has me declare the querydef
name as a variable, and then use it in the code:
dim qdf as QueryDef
qdf.SQL = strAlternateSQL
I had declared a string variable as qDefName giving the name of the
query
qDefName.SQL = strAlternateSQL
but I get back the error "Invalid qualifier". So if I have an
existing query, how do I work with it as a queryDef in 2000?