View Full Version : VBA Passing in Textbox into a function Help


Jerry8989
04-23-2008, 08:11 AM
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

KeithG
04-23-2008, 09:31 AM
I would assume the data type is date/time, correct?

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