Form pop-up on start based on query/code (1 Viewer)

N

northernMONKEY

Guest
Hi

I've got a query which lists animal with ages between 0 and 30 months. What I want to do is when the access database loads, list all those animals that are between 26 - 30 months old (obviously the query i currently have can be easily adapted. This should not be displayed if no animals are in this age category and should just continue to the main menu. Does anyone know how to do this?

regards
Chris
 

DES

Technoweenie
Local time
Today, 06:59
Joined
Apr 17, 2001
Messages
245
Sure, once you make up the form with the info you want on it, go to the startup settings and set that form to start first.

Then on its OnOpen event put something like this.

Dim vCounter as Integer

vCounter = DCount("[Any Field in your query]","The name of your query")
if vCounter < 1 then
Docmd.Close "The name of the form"
end if

What this will do is count the number of records in your query where the age is whatever. If there are none then it will close the form.

In the OnClose event I would then tell it what form to open next.

HTH
 

Users who are viewing this thread

Top Bottom