I would like to ck 2 txtboxes to make sure they contain valid date values. the code will be the same for each so i wanted to write a sub and pass in the txtbox, but my vba is not in a good mood. my code
Private Sub cmdQry_Click()
On Error GoTo Err_cmdQry_Click
Dim txtbox As New TextBox
txtbox = txtBeg 'txtbeg is name of txt on form
Private Sub validateDates(txtbox As TextBox)
If Not IsDate(.Text) Then
MsgBox "You must enter a valid DATE! ", , "MichaelSoft"
.BackColor = vbYellow
by the way the exix_cmdQry_click is in another sub. Can i do that???
gosh ...i did this a few days ago but i forget the details.
drop the SetFocus AND the .Text
(cos .Value doesn't need focus - better, use .Value ALWAYS unless you have a specific reason not to want to address boxes not having focus)
if this doesn't fix it AND if i remember which lump of my code passed a txtbox, i'll get back to you.