Preventing Certain Values/Entries

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

Guest

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?
 
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
 
I get an error message: "Compile Error: Expected Expression"

-Doug

Ofer Cohen said:
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


Doug Dickey said:
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?
 
Can you post your code?

--
Good Luck
BS"D


Doug Dickey said:
I get an error message: "Compile Error: Expected Expression"

-Doug

Ofer Cohen said:
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


Doug Dickey said:
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?
 
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

Ofer Cohen said:
Can you post your code?

--
Good Luck
BS"D


Doug Dickey said:
I get an error message: "Compile Error: Expected Expression"

-Doug

Ofer Cohen said:
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?
 
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] & "#")
MsgBox " date is unavailable"
Cancel = True 'wont let the user exit the text field
End If
End If
End Sub

--
Good Luck
BS"D


Doug Dickey said:
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

Ofer Cohen said:
Can you post your code?

--
Good Luck
BS"D


Doug Dickey said:
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?
 
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] & "#")
MsgBox " date is unavailable"
Cancel = True 'wont let the user exit the text field
End If
End If
End Sub

--
Good Luck
BS"D


Doug Dickey said:
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

Ofer Cohen said:
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?
 
Try and move the code to the OnExit event of the text field, and set the
focus to the date field when the calendar control is closed.

--
Good Luck
BS"D


Doug Dickey said:
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] & "#")
MsgBox " date is unavailable"
Cancel = True 'wont let the user exit the text field
End If
End If
End Sub

--
Good Luck
BS"D


Doug Dickey said:
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?
 
Go you're good! Thanks again!
-Doug

Ofer Cohen said:
Try and move the code to the OnExit event of the text field, and set the
focus to the date field when the calendar control is closed.

--
Good Luck
BS"D


Doug Dickey said:
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?
 
Glad I could help, Good Luck



Doug Dickey said:
Go you're good! Thanks again!
-Doug

Ofer Cohen said:
Try and move the code to the OnExit event of the text field, and set the
focus to the date field when the calendar control is closed.

--
Good Luck
BS"D


Doug Dickey said:
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

:

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?
 
Back
Top