how do I run a query on load of form? (1 Viewer)

shabbaranks

Registered User.
Local time
Today, 09:25
Joined
Oct 17, 2011
Messages
300
Hi all...

I have a query which checks a table to see if there are any new additions to it (the table is a linked table). Can anyone please tell me how I get the query to run on startup of the database? Does it require some VBA?

Thanks
 

Guus2005

AWF VIP
Local time
Today, 10:25
Joined
Jun 26, 2007
Messages
2,641
Yes, it does require some VBA.
There are two events you can use for this purpose, Form_Open(can be cancelled) and Form_Load.

In the Form_Open event you can run a query and if you don't like what you see, cancel the form to open.
In the Form_Load event you can also run query.
The Form_Open event fires once and the Form_Load event fires each time the form receives focus.

HTH:D
 

Guus2005

AWF VIP
Local time
Today, 10:25
Joined
Jun 26, 2007
Messages
2,641
... you can also run a Macro to run the query. But VBA gives you more control.

HTH:D
 

shabbaranks

Registered User.
Local time
Today, 09:25
Joined
Oct 17, 2011
Messages
300
Hey,

Thanks for the replies, I managed to do it using

Code:
DoCmd.OpenQuery "ImportNewProjectsQuery"

Thanks again :)
 

Users who are viewing this thread

Top Bottom