Sorry about that...
Textbox name is txttourdate
Table Name is tblblockdates
Field name that has the blocked dates is BlockedDates
Anyway, I did what you said for the BeforeUpdate event of the txttourdate box:
Private Sub txttourdate_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[BlockedDate]", "tblblockdates", _
"[BlockedDate] = #" & Me.txttourdate & "#")) Then
MsgBox Me.txttourdate & " Is Blocked"
Cancel = True
End If
End Sub
One of the dates in the BlockedDates is 12/18/2005. When I choose that date
for the txttourdate box, I do not get the error message. Let me know what you
think, and thanks a lot for the help!
-Doug
Klatuu said:
Since I don't know the name of the textbox (not a field, fields are in
tables) the date goes in, the name of your table, or the name of the field in
the table that has the blocked dates, I will make them up and you can change
the code to meet your needs. Put this in the Before Update event of the text
box on the form where the date in entered from the calendar:
If Not IsNull(DLookup("[BLOCKED_DATE]","BlockedDateTable", _
"[BLOCKED_DATE] = #" & Me.txtDateFromCalendar & "#")) Then
MsgBox Me.txtDateFromCalendar & " Is Blocked"
Cancel = True
End If
:
I have a table with a list of dates "BlockedDates" that are days the office
is closed or is a holiday. On a form there is date field that when double
clicked, opens up a calendar. When a date is chosen on the calendar, the date
is put in that field. How do I prevent someone from choosing a date that is
listed in the BlockedDates table? Either by MsgBox, Validation Rule,
whatever.
Thanks SOOO Much for the help
-Doug