Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use OnTimer Event for Queries 1

Status
Not open for further replies.

intrepidtechie

Programmer
Nov 6, 2004
27
0
0
US
Could anyone provide an example to use a "OnTimer Event" to run a query.
 
The ontimer events are in forms.

If you make a form, and select properties, events, then the on timer intervel is there for you to change, and you can say run a macro at that intervel.

The macro can run your querry.

ChaZ
 
Hi,

You need to set your timer interval of form to the time you want

1000 = 1 sec

Now On Timer Event of your form just write

docmd.OpenQuery "QueryName",acViewNormal,acReadOnly

You can make it look a bit fancy by putting user option

If MsgBox ("The system needs to run some query now. Do you want to proceed",vbYesNo)=VbYes Then

docmd.OpenQuery "QueryName",acViewNormal,acReadOnly

End if

Hope thats what you are looking for

Cheers!
ÙÇãá

It's important to learn the rules so that you know how to break them.
 
I am sorry guys this didnt work. Maybe I did it wrong.
Can you suggest a simple macro to run a query automatically eachtime the database gets updated.
More information. The database gets updated by a VB routine that imports new data everyday morning (like a batch process). The query is written to update a field in the database to correct some values. the name of the query is Query_01.
This macro should run immeditalty the database has finished its updates.

 
The safest way, in my opinion, is the VB routine launching the query after the database updates.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hello PHV,
Could you suggest a code snippet that can do the Vb routine to launch a query after DB updates
 
A starting point:
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase "\path\to\database.mdb"
appAccess.DoCmd.OpenQuery "QueryName"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top