How to call a query in my vba module (1 Viewer)

unixkid

New member
Local time
Today, 01:11
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
 

JANR

Registered User.
Local time
Today, 09:11
Joined
Jan 21, 2009
Messages
1,623
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:

kevala

New member
Local time
Today, 01:11
Joined
Dec 6, 2014
Messages
1
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

Top Bottom