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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Excel Vba to change displayed year automatically. 14
Excel Help with dates 2
Validation in child form 1
Macro for Dates 5
Restrict Entry of Dates in Access 2003 4
display form on a specific date 2
Week Ending Dates 2
last date of the month 5

Back
Top