Works Great! But it only works when I manually type in a date. Technically,
when you double-click on that text box, a calendar will pop up, you choose
the date, the calendar closes and the date is entered into the text box. If
you chose one of the unavailable dates using the double-click calendar
method, the message box won't appear. Any ideas on how to fix this?
I appreciate the help!
-Doug
Ofer Cohen said:
You are missing one "End If", also the second if make it in one line
Try
Private Sub DatOfTour_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.[DateOfTour]) Then
If DCount("*","tblBadDates","unavailable = #" & Me.[DateOfTour] & "#")
0 Then
MsgBox " date is unavailable"
Cancel = True 'wont let the user exit the text field
End If
End If
End Sub
--
Good Luck
BS"D
:
Private Sub DatOfTour_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.[DateOfTour]) Then
If DCount("*","tblBadDates","unavailable = #" &
Me.[DateOfTour] & "#") > 0 Then
MsgBox " date is unavailable"
Cancel = True 'wont let the user exit the text field
End If
End Sub
-Doug
:
Can you post your code?
--
Good Luck
BS"D
:
I get an error message: "Compile Error: Expected Expression"
-Doug
:
Ty this on the before update event of the text field
If Not IsNull(Me.[DateOfTour]) Then
If DCount("*","tblBadDates","UNAVAILABLEDateFieldName = #" &
Me.[DateOfTour] & "#") > 0 Then
MsgBox " date is unavailable"
Cancel = True 'wont let the user exit the text field
End If
End If
--
Good Luck
BS"D
:
I have a text box labeled DateOfTour. I have a table with a list of dates
that are UNAVAILABLE (tblBadDates). Is there any way that I can prevent, or
at least have a message that pops up that says this date is unavailable when
someone enters one of those bad dates into the text box?