entering data to tables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

my database has a table where users enter data directly. is there away i can make sure that they don't enter a date older than a certain point when they enter a new record with out affecting data that is already in the table? and can i lock older records to prevent changes

thanx
 
Don't let them enter directly into the table. Create a form for them to use,
and you can include whatever validation you want.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Wesley said:
my database has a table where users enter data directly. is there away i
can make sure that they don't enter a date older than a certain point when
they enter a new record with out affecting data that is already in the
table? and can i lock older records to prevent changes?
 
To check that a value is in range, use the BeforeUpdate event of the
control, or of the form. Example:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If DateDiff("m", Me.[YourDateFieldNameHere], Date) > 6 Then
If MsgBox("More than 6 months ago?", vbYesNo+vbDefaultButton2) <>
vbYes Then
Cancel = True
End If
End If
End Sub


To prevent changes to records that are older than a certain date, use the
Current event procedure of the form to change the form's AllowEdits
property:

Private Sub Form_Current()
Dim bLock As boolean
If DateDiff("m", Me.[YourDateFieldNameHere], Date) > 6 Then
bLock = True
End If
Me.AllowEdits = Not bLock
Me.AllowDeletions = Not bLock
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.
Wesley said:
my database has a table where users enter data directly. is there away i
can make sure that they don't enter a date older than a certain point when
they enter a new record with out affecting data that is already in the
table? and can i lock older records to prevent changes?
 
Enter a validation into the date fields properties
such as >date(), or <date() or <=Date()-7 ect...

And enter the validation text to display what the user is
doing wrong.
validation rule: >=date()-7
validation text: You must enter a date no later than
1 week prior to today.
-----Original Message-----
my database has a table where users enter data
directly. is there away i can make sure that they don't
enter a date older than a certain point when they enter a
new record with out affecting data that is already in the
table? and can i lock older records to prevent changes?
 
Back
Top