how to prevent records from editing or deletion

G

Guest

hi
i have my Patients form in which i enter Patients details including expenses
..so i want a to have a button to protect a record from editing or
deletion.and at the same time have the option to unprotect it or even delete
it. this will prevent editing records of previous year/s which may a user do
by mistake ( as one patient may have many records because for each travel he
will have a new record.)
 
G

Guest

On the oncurrent event of te form, you can check for the year , and lock the
records according

Private Sub Form_Current()
If Year(Me.DateField) < Year(date()) Then
Me.AllowDeletions = False
Me.AllowEdits = False
Else
Me.AllowDeletions = True
Me.AllowEdits = True
End If
End Sub
 
G

Guest

thanks ofer.
i have tried this.my question now is how to unprotect a record .how to get
access to one of the protected records.actually, i have two tables .one is
Patients which will hold patients personal inf and medical.the other is
exense reports which will hold the expenses.i am receiving invoices batches
and have to account.after entering each batch(which will have manual no) i
print the expense details entered for that batch which should tally with the
total amt of invoices. so , when i make sure the amount is tying up , at that
stage i want to have option to protect these records ( which are in the
subform of the main Patients form) from being edited or deleted.of course
this is regardless of the protection of the main form.because i may receive
invoices for a particular patient after one or two years only, which
according to the event proc.you gave me , will be protected.

thank you
 

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