How to call a query in my vba module

unixkid

New member
Local time
Today, 03:06
Joined
Dec 14, 2010
Messages
7
Hey guys,

I'm fairly new to this all so bear with me!

I have a query called "ClearTable Query" which clears the contents of a table, how do I call this in my vba module thingy? (i.e. the bit where you write the whole
sub myfunction
...
end sub

also, when i run the query on its own, it asks me for confirmation, how do I fix it so it just does the query without asking?

Thanks
 
Code:
Sub ClearTable()
Currentdb.Execute("ClearTable"), dbFailOnError
End Sub

This will run the query without any prompts from Access, or you can use this and you don't need your query:

Code:
Sub ClearTable()
Currentdb.Execute "DELETE * From YourTableName", dbfailOnError
End Sub

JR
 
Last edited:
Add this line to your code.
DoCmd.SetWarning (False)

This will disable all the confirmation messages. However, this will also disable all other system messages. So it may be prudent to set the SetWarnings property to True after you execute the function. I hope this helps
 

Users who are viewing this thread

Back
Top Bottom