Hi,
Im new to vba. Literally started learning the language 3 days ago. I have created a textbox within a userform so that my users can input a date. But i keep getting "object required." please help. here is my code.
Dim Final_Date_of_Service As Date
Private Sub Date_of_Service_Txtbox_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim Date_of_Service As Date
Set Date_of_Service = Date_of_Service_Txtbox
If Date_of_Service <> "" Then
If IsDate(Date_of_Service) Then
Date_of_Service = Format(Date_of_Service, "MMDDYYYY")
Final_Date_of_Service = Date_of_Service
Else
MsgBox "Please enter a valid date in the format MMDDYYYY!", vbCritical
Date_of_Service = ""
Cancel = True
End If
End If
End Sub
Im new to vba. Literally started learning the language 3 days ago. I have created a textbox within a userform so that my users can input a date. But i keep getting "object required." please help. here is my code.
Dim Final_Date_of_Service As Date
Private Sub Date_of_Service_Txtbox_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim Date_of_Service As Date
Set Date_of_Service = Date_of_Service_Txtbox
If Date_of_Service <> "" Then
If IsDate(Date_of_Service) Then
Date_of_Service = Format(Date_of_Service, "MMDDYYYY")
Final_Date_of_Service = Date_of_Service
Else
MsgBox "Please enter a valid date in the format MMDDYYYY!", vbCritical
Date_of_Service = ""
Cancel = True
End If
End If
End Sub