how to save a query with new Name VBA?

  • Thread starter Thread starter woodybarry
  • Start date Start date
W

woodybarry

I have a very complicated form to create a query with all kinds of
dropbox, listbox, combo etc. I'd like my users to save each query with
his own queryname in VBA. It is like a MSG box that asks for a name of
the query, then save the current query as the new query. So, next
time, users do not need to choose all the options again. Is there any
function or Macro in MS Access to do so? Thanks,

WoodyBarry
 
You can either use a text box or an input box to get the name. The use the
CreateQueryDef method to create and save the query.
 
Thanks fore reply. My built query is very complicated, it is built by
different procedures depending on customer's options. I wonder if
there is way to copy query sqltxt directly instead of creating queries
twice as a backup. In that way, I do not have to go through each
procedure.
 
Thanks fore reply. My built query is very complicated, it is built by
different procedures depending on customer's options. I wonder if
there is way to copy query sqltxt directly instead of creating queries
twice as a backup. In that way, I do not have to go through each
procedure.

A Querydef object has a SQL property which is a text string that you could use
to create a new query, using the CreateQuerydef() method. Seems roundabout but
it should work!

John W. Vinson [MVP]
 
Back
Top