how to save a query with new Name VBA?

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
 
K

Klatuu

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.
 
W

woodybarry

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.
 
J

John W. Vinson

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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top