I have a form created in VBA, In the form is a number of textboxes..... What i need is if i dont put a date in txtDate a message tells me to insert correct date (dd/mm/yyyy).
Every time i use codes i have found on this forum it goes into a loop and i have to ctrl/alt/delete to get out of it....
<!-- BEGIN TEMPLATE: bbcode_code -->
[Code:]
Private Sub cmdCancel_Click()
ModAdvFilter.CancelProcess = True
Me.Hide
Unload Me
End Sub
Private Sub cmdOK_Click()
ModAdvFilter.CancelProcess = False
ModAdvFilter.RegInfo = Me.txtReg.Text
ModAdvFilter.SerialNum = Me.txtSN.Text
ModAdvFilter.TheDate = Me.txtDate.Text
Me.Hide
Unload Me
End Sub
Private Sub txtDate_Change()
Me.cmdOK.Enabled = HasCriteria
End Sub
Private Sub txtReg_Change()
Me.cmdOK.Enabled = HasCriteria
End Sub
Private Sub txtSN_Change()
Me.cmdOK.Enabled = HasCriteria
End Sub
Private Sub UserForm_Initialize()
ModAdvFilter.CancelProcess = True
Me.cmdOK.Enabled = HasCriteria
txtDate.Text = Format(Date, "dd/mm/yyyy")
End Sub
Private Function HasCriteria() As Boolean
If Len(Trim(Me.txtDate)) > 0 Or Len(Trim(Me.txtReg)) > 0 Or Len(Trim(Me.txtSN)) > 0 Then
HasCriteria = True
Else
HasCriteria = False
End If
End Function
[/code]
Please help it is driving me mad........
<!-- / message --><!-- BEGIN TEMPLATE: ad_showthread_firstpost_sig --><!-- END TEMPLATE: ad_showthread_firstpost_sig -->
<STYLE>.alt2 font {font: 11px monospace !important;color: #333 !important;}</STYLE>
Every time i use codes i have found on this forum it goes into a loop and i have to ctrl/alt/delete to get out of it....
<!-- BEGIN TEMPLATE: bbcode_code -->
[Code:]
Private Sub cmdCancel_Click()
ModAdvFilter.CancelProcess = True
Me.Hide
Unload Me
End Sub
Private Sub cmdOK_Click()
ModAdvFilter.CancelProcess = False
ModAdvFilter.RegInfo = Me.txtReg.Text
ModAdvFilter.SerialNum = Me.txtSN.Text
ModAdvFilter.TheDate = Me.txtDate.Text
Me.Hide
Unload Me
End Sub
Private Sub txtDate_Change()
Me.cmdOK.Enabled = HasCriteria
End Sub
Private Sub txtReg_Change()
Me.cmdOK.Enabled = HasCriteria
End Sub
Private Sub txtSN_Change()
Me.cmdOK.Enabled = HasCriteria
End Sub
Private Sub UserForm_Initialize()
ModAdvFilter.CancelProcess = True
Me.cmdOK.Enabled = HasCriteria
txtDate.Text = Format(Date, "dd/mm/yyyy")
End Sub
Private Function HasCriteria() As Boolean
If Len(Trim(Me.txtDate)) > 0 Or Len(Trim(Me.txtReg)) > 0 Or Len(Trim(Me.txtSN)) > 0 Then
HasCriteria = True
Else
HasCriteria = False
End If
End Function
[/code]
Please help it is driving me mad........
<!-- / message --><!-- BEGIN TEMPLATE: ad_showthread_firstpost_sig --><!-- END TEMPLATE: ad_showthread_firstpost_sig -->
<!-- controls -->http://www.excelforum.com/excel-programming/772499-text-box-only-accept-dd-mm-yyyy-msg-if-not.html
<STYLE>.alt2 font {font: 11px monospace !important;color: #333 !important;}</STYLE>