Ensure correct date sequence

F

felton

I am keying in data into a results table and I need to setup a checking
process during the data entry so that each new results record is dated is
after, not before or equal to, the date in the previous records. Does anyone
know how to set this up? In other words, I need Access to prevent both an
earlier date or the same date already entered from any previous records.

Many thanks.
 
P

PieterLinden via AccessMonster.com

felton said:
I am keying in data into a results table and I need to setup a checking
process during the data entry so that each new results record is dated is
after, not before or equal to, the date in the previous records. Does anyone
know how to set this up? In other words, I need Access to prevent both an
earlier date or the same date already entered from any previous records.

Many thanks.

You would have to use some code in the BeforeInsert event and use DMAX to get
the latest date and make sure the one being entered was greater than that...

Private Sub Text2_BeforeUpdate(Cancel As Integer)
If Me.Text2 <= DMax("ReportDate", "tblNonNormal") Then
MsgBox "Has to be later all other entries", vbOKOnly + vbInformation
Cancel = True
End If
End Sub
 

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

Top