View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] shahzad4u_ksa@yahoo.com is offline
external usenet poster
 
Posts: 68
Default Restriction for the Date Field in UserForm


I have a UserForm and I put the restriction on the "DatePurchase"
textbox. so user can not skip this field. it is working fine. I used
the following code for that.


Private Sub DatePurchase_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not IsDate(DatePurchase) Then
MsgBox "Input must be a date in the format: 'dd/mmm/yyyy'"
Cancel = True
Else
DatePurchase = Format(DatePurchase, "dd/mmm/yyyy")
End If
End Sub



Private Sub CloseForm_Click()

Unload Me

End Sub


when I Load the UserForm and I dont want to go for entry and I want to
close this form by close button, with Unload me command. then my
userform is not going to close at all, unless I feed the Date in
"DatePurchase" Field.

when I hit the close button without feeding the Date, the Input
message is appearing. "Input must be a date in the format: 'dd/mmm/
yyyy'"

I want my Form to be close when I hit the close button


Pls give me any suggession.......

Regards.

Shahzad