calling a query

  • Thread starter Thread starter cgoatly
  • Start date Start date
C

cgoatly

Guest
Hi,

I'm sure this is quite basic, but still, I'm stumped!
I'm trying to call an update query in vba behind a form that I have created.
The query is already set up in the database in the query section but I'm unsure how to call it from the code!

If anyone could help, that would be great!

Thanks a lot,

Caroline
 
Hi Caroline
I use the following

Code:
' Set all invoice active flags to "No"
    DoCmd.SetWarnings False
        strQryDef = "qupdInvActNo"
            DoCmd.OpenQuery strQryDef, acViewNormal, acEdit
    DoCmd.SetWarnings True

You have to define strQryDef as a string and then it works fine. The benefit is that you can then copy the little quartet of lines and just change the query name.
Hope this helps
 
if the query already exists then
DoCmd.OpenQuery "Your Query"

HTH

Peter
 
THANKS BAT17!!! I was doing it much to difficult! Very nice if you want to requery your subform after de update query. Just 2 lines VBA. THNX m8! :D
 
Remember though, that unless you set the warnings off before you run the query you will get a "do you want to run this query" message which can be very confusing for a user.
And further, if you switch off the warnings you need to switch them back on again!
Good luck
 

Users who are viewing this thread

Back
Top Bottom