LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default how to generate date error message

I have a user form that works great but I have one last item to fix.
If someone types in a date wrong, it will not update the spreadsheet
with any info and does not give an option to fix the date. What I
would like is an error message and not to update the spreadsheet but
to be able to fix the date. Once that is done, click on OK and then
it can update sheet.
Here is what I have:


Private Sub OK_Click()
Dim RowCount As Long

If Me.txtName.Value = "" Then
MsgBox "Please enter Employee's name", vbExclamation,
"PSHCPNUMBERS"
Me.txtName.SetFocus
Exit Sub
End If
If Me.TXTPRI.Value = "" Then
MsgBox "Please enter Employee's PRI", vbExclamation,
"PSHCPNUMBERS"
Me.txtName.SetFocus
Exit Sub
End If
If Me.CBODEPARTMENT.Value = "" Then
MsgBox "Please Choose a Department", vbExclamation,
"PSHCPNUMBERS"
Me.txtName.SetFocus
Exit Sub
End If
If Me.cboPSHCPLEVEL.Value = "" Then
MsgBox "Please Choose PSHCP Level", vbExclamation,
"PSHCPNUMBERS"
Me.txtName.SetFocus
Exit Sub
End If
If Me.TXTDEDUCTIONDATE.Value = "" Then
MsgBox "Please Enter a Deducton Date", vbExclamation,
"PSHCPNUMBERS"
Me.txtName.SetFocus
Exit Sub
End If
If Me.TXTCOVERAGEDATE.Value = "" Then
MsgBox "Please Enter a Coverage Date", vbExclamation,
"PSHCPNUMBERS"
Me.txtName.SetFocus
Exit Sub
End If
RowCount =
Worksheets("PSHCP").Range("A1").CurrentRegion.Rows .Count
With Worksheets("PSHCP").Range("A1")
.Offset(RowCount, 7).Value = Format(Now, "dd/mmm/yyyy
hh:nn:ss") & Application.UserName
.Offset(RowCount, 0).Value = Me.txtName.Value
.Offset(RowCount, 1).Value = Me.TXTPRI.Value
.Offset(RowCount, 2).Value = Me.CBODEPARTMENT.Value
.Offset(RowCount, 3).Value = Me.cboPSHCPLEVEL.Value
.Offset(RowCount, 4).Value = DateValue(TXTDEDUCTIONDATE.Value)
.Offset(RowCount, 5).Value = DateValue(TXTCOVERAGEDATE.Value)
End With
Unload Me


End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error message needed if incorrect Date Of Birth (DOB) entered Craig Excel Worksheet Functions 5 January 27th 10 08:24 PM
Date error message (VBA) cdb Excel Programming 3 August 1st 07 07:52 PM
Find Date error message FIRSTROUNDKO via OfficeKB.com Excel Programming 2 September 28th 06 12:28 PM
Adding a date to calender to automatially generate another date? Crystal Long Excel Worksheet Functions 1 January 3rd 06 10:19 PM
Input Date Error Message Dominique Feteau[_2_] Excel Programming 2 December 4th 04 08:00 AM


All times are GMT +1. The time now is 10:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"