What I have is a userform that displays the last date data was entered in one of its many textboxes and what I'm trying to prevent is the next date from being accidentally skipped. I have something similar on another userform that checks the last time an entry was made and that the next entry made is 2 hours after that.
I figure it's got to be something simple that I'm missing or not seeing. I've put the coding below for each userform and hope one of you can help me figure this out.
This is the coding I can't get to work right
Midnights WorkSheet <--All the coding here does not work
'checks any date is not reentered <--This works fine
If WorksheetFunction.CountIf(ws.Columns(2), Trim(Me.cboDate.Value)) > 0 Then
MsgBox "Sorry, " & Trim(Me.cboDate.Value) & " exists already", vbExclamation, "Invalid Date Entry"
MsgBox "If you are correcting an error," & vbFl & "Please close this form and select Edit instead", vbExclamation, "Fix The Date"
Exit Sub
End If
'checks that there is only 1 day between each entry <--This does not work properly, runs every time
If cboDate.Value <> Format(DateAdd("d", 1, txtMidDate2.Value), "dd-mmm-yyyy") Then
MsgBox "The " & Format(DateAdd("d", 1, txtLastDate.Value), "dd-mmm-yyyy") & " Midnight Report is missing!" & vbLf & "Please enter it first", vbExclamation, "Missing An Entry"
Exit Sub
End If
This is the coding that works for the second userform
Thermals WorkSheet <--All the coding here works fine
'checks any date and time is not reentered
If WorksheetFunction.CountIfs(ws.Columns(2), Trim(Me.cboDate.Value), ws.Columns(3), Trim(Me.cboTime.Value)) > 0 Then
MsgBox "Sorry, " & Trim(Me.cboDate.Value) & " at " & Trim(Me.cboTime.Value) & " exists already", vbExclamation, "Invalid Time Entry"
MsgBox "If you are correcting an error," & vbLf & "Please close this form and select Edit instead", vbExclamation, "Fix The Time"
Exit Sub
End If
'checks that there is only 2 hours between each entry
If cboTime.Value <> Format(DateAdd("h", 2, txtLTime.Value), "hh:mm") Then
MsgBox "The " & Format(DateAdd("h", 2, txtLTime.Value), "hh:mm") & " Thermals are missing", vbExclamation, "Missing An Entry"
Exit Sub
End If
Bookmarks