VBA Passing in Textbox into a function Help

Jerry8989

Registered User.
Local time
Yesterday, 20:47
Joined
Mar 16, 2006
Messages
64
I have many date fields that I want to validate a range for. I created this function to pass in the text so that it will verify the date and then display a message if it is out of range then cancel the change so it isn't committed.

Private Sub txtInDate_BeforeUpdate(Cancel As Integer)
ValidationRFQDates (txtInDate)
End Sub

Private Sub ValidationRFQDates(txtField As TextBox)
If (DateValidation(txtField) = 0) Then
MsgBox "Date Must be Greater Than 1/1/1999 and Less Than " & DateAdd("yyyy", 10, Date)
Cancel = True
txtField.Undo
End If
End Sub

I keeps telling me "Object Required" on ValidationRFQDates (txtInDate)

Thank You
 
I would assume the data type is date/time, correct?

You need to use txtfield as date instead of txtfield as textbox
 

Users who are viewing this thread

Back
Top Bottom