Validating date entries in the Ledger.

  • Thread starter Thread starter Frank Martin
  • Start date Start date
F

Frank Martin

Our accounting and reporting are done on a monthly basis.

Sometimes a date is keyed in incorrectly (such as 1/11/04 instead of
11/1/04) and this will cause imbalance in the monthly tax printout and other
reports.

We need a simple way to validate a date to check if the date entry is indeed
in the current month.

Maybe a small error message saying "Check date Y/N" if a date out of the
current month is entered.

Please help, Frank
 
Use the BeforeUpdate event of the text box on the form where you enter the
date.

This example checks the date is within a week of today:

Private Sub TransactDate_BeforeUpdate(Cancel As Integer)
If Abs(Me.[TransactDate] - Date()) > 7 Then
If MsgBox("Really?", vbYesNo+vbDefaultButton2) <> vbYes Then
Cancel = True
End If
End If
End Sub
 
Frank,
Very basically... (use your own names)

Private Sub MyDate_BeforeUpdate(Cancel As Integer)
If Month(MyDate) <> Month(Date) Then
Beep
MsgBox "Invalid Month in Date", vbOKOnly, "Invalid Date"
End If
End Sub

You could also use the ValidationRule for MyDate..
"Month([Field3])<>Month(Date())"
and Validation Text..
"Invalid Month"
hth
Al Camp
 
Back
Top