ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   textbox validation for date and condition (https://www.excelbanter.com/excel-programming/412605-textbox-validation-date-condition.html)

tkraju via OfficeKB.com

textbox validation for date and condition
 
How to validate a textbox entry(userform) for date entry and not be greater
than today's date.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200806/1


Harald Staff[_2_]

textbox validation for date and condition
 
This is just as much a When question, you must do everything after entry is
done:

Private Sub CommandButton1_Click()
Dim DT As Date
On Error Resume Next
DT = DateValue(Me.TextBox1.Text)
Select Case DT
Case 0 To DateSerial(1910, 1, 1)
MsgBox "no good"
Me.TextBox1.Text = ""
Me.TextBox1.SetFocus
Case Date + 1 To Date + 1000000
MsgBox "no good"
Me.TextBox1.Text = ""
Me.TextBox1.SetFocus
Case Else
MsgBox DT
End Select
End Sub


"tkraju via OfficeKB.com" <u16627@uwe wrote in message
news:85abf58b3f3ac@uwe...
How to validate a textbox entry(userform) for date entry and not be
greater
than today's date.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200806/1



tkraju via OfficeKB.com

textbox validation for date and condition
 
thank you !!

Harald Staff wrote:
This is just as much a When question, you must do everything after entry is
done:

Private Sub CommandButton1_Click()
Dim DT As Date
On Error Resume Next
DT = DateValue(Me.TextBox1.Text)
Select Case DT
Case 0 To DateSerial(1910, 1, 1)
MsgBox "no good"
Me.TextBox1.Text = ""
Me.TextBox1.SetFocus
Case Date + 1 To Date + 1000000
MsgBox "no good"
Me.TextBox1.Text = ""
Me.TextBox1.SetFocus
Case Else
MsgBox DT
End Select
End Sub

How to validate a textbox entry(userform) for date entry and not be
greater
than today's date.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200806/1



All times are GMT +1. The time now is 11:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com