Hi,In my Access97 database, there are 20 tables, c-1-1, c-1-2, c-1-3,etc. I need to create 20 select queries like qryc1,qryc2, qryc3, and so on to join each table with tblMaster. I want to use VBA code---tabledef and querydef to create those select queries like this:
For each tabledef in db.tabledefs
if tdf.name like "c-1*"
sql="select "&tdf.name&".f1,"&tdf.name&".f2 from "&tbl.name&" right join on tblMaster on tblmaster.f1="&tblname&".f1"
set qdf=db.createquerydef("qry"&left(tdf.name,1)&right(tdf.name,1),sql)
What do I do then if I just want to create the query and not run them? Much thanks.
For each tabledef in db.tabledefs
if tdf.name like "c-1*"
sql="select "&tdf.name&".f1,"&tdf.name&".f2 from "&tbl.name&" right join on tblMaster on tblmaster.f1="&tblname&".f1"
set qdf=db.createquerydef("qry"&left(tdf.name,1)&right(tdf.name,1),sql)
What do I do then if I just want to create the query and not run them? Much thanks.