Block out dates

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a list of dates (in a table) that I do not want to have available when
someone inputs a certain date in the date box. I would like a message to pop
up saying "You cannot schedule an appointment on this date" . How do I go
about doing this?
 
Perhaps use the BeforeUpdate event of the textbox to do this test:

Private Sub TextBoxName_BeforeUpdate(Cancel As Integer)
If Me.TextBoxName.Value = DCount("*", "DateTableName", _
"DatesNotAllowedFieldName = #" & _
Me.TextBoxName.Value & "#") > 0 Then
Cancel = True
MsgBox "You cannot schedule an appointment on this date."
End If
End Sub
 
I've been working on this for quite some time now, and I can't get it to work
still. Here is my code based on what you gave me:

Private Sub DateOfTour_Click()
If Me.DateOfTour.Value = DCount("*", "UnavailableDates",_
"Dates = #" & _
Me.DateOfTour.Value & "#") > 0 Then
Cancel = True
MsgBox "You cannot schedule an appointment on this date."
End If
End Sub

Nothing was happening when I entered a date that was listed in the
unavailable dates table. I then created another text box that would reflect
the date I chose in the first date box and added that code on the click
event. All I get now is "Compile Error: Syntax Error" I checked the spelling
of everything, but to no avail it still does not work.

I use a calendar control in a pop up menu to choose a date from the calendar
that is added to the Date of Tour box. Is there any way to just block certain
dates on the calendar rather than having a message box that pops up when you
choose an unavailable tour date?

Thanks A LOT!
 
Is the DateOfTour control the popup calendar control (ActiveX)? Is that the
built-in one from MS?

I'm guessing that this control doesn't have a value yet when you click it?
Put a breakpoint on the code step with the DCount function in it... what is
the value of the DateOfControl control at that point?

--

Ken Snell
<MS ACCESS MVP>
 
Back
Top