Open Form with Condition

hootie318

Registered User.
Local time
Today, 18:34
Joined
Oct 28, 2003
Messages
130
I have searched, but I cant find a thread for this.

I have a calendar that I input when people are going to be off. If there is nothing for that date then the record is blank. I have a form that opens when the db opens attached to the date on the switchboard. If no one is off then the form opens blank because there is no date in the table to match. What I want to do is have a something built into the code that says if there is no match (null??) then dont open the form.

DoCmd.OpenForm "PopUpCalendar", acNormal, , "[Calendar]![Date] = Forms![Switchboard]![MainDate]"
 
Put this code in your Forms OnLoad event:

If DCount("MainDate", "tblHolidays", "MainDate = " & Forms!Switchboard!MainDate) = 0 Then
DoCmd.close
End If

This will look through your table for any records with the date specified on the switchboard and close the form if there is no matches.
There is probably a more ethical way to do this but it does the trick for me.
 

Users who are viewing this thread

Back
Top Bottom