record disabling

jacks

Registered User.
Local time
Today, 23:03
Joined
Jun 3, 2007
Messages
28
1. I want to disable changing a record after it has been updated.
I was thinking about adding a checkbox "lock" and on every Current event look if the record is locked.. but I feel there must be a simpler way.

any suggestions ?
thnx in advance.
 
Last edited:
When you say you want to disable changing a record after it has been updated, does that mean when a new entry has been created, or when a change has occurred? If it is when a change has occurred, does that mean that an existing record can have one change made to it and after that it can't ever be changed again?
 
Bob's questions need to be answered for us to help you. Placing a checkbox will work, but it really has to be invisible to your users, else what have you accomplished? If it's visible, they can simply uncheck it, make changes, then check it again.
 
bob's stop on .

this is what I do
i have a quote screen that can be amended tweaked to your hearts delight - but upon pushing of the transaction button - it copies all of the data to a history table and you can view it via a duplicated of the forms used to enter the data , but they are called history and they do not allow edits - the underlying quote can be amended again - i am in insurance so need to do endorsements to the main record and then hit the transaction button and again it copies my data over in to the history table (which will now have 2 records) in it .


this might not answer your question, but might give some insight ...
 
When you say you want to disable changing a record after it has been updated, does that mean when a new entry has been created, or when a change has occurred? If it is when a change has occurred, does that mean that an existing record can have one change made to it and after that it can't ever be changed again?

yes.

The form with the input fields has a button. Pressing the button causes a few calculations and a few form fields to be filled in. After that, I don't want to mess up the record again by accidently changing the record again. I want to protect the record against changing it.

But I don't know which command or method is appropiate to realize this.
 
Here's one way to do it, Jacks:

In your table add a field, datatype Yes/No
Set its Default to No

In the form's Design View place this field on the form
Name it RecLocked

Then place this code behind your form

Code:
Private Sub YourCommandButton_Click()
  'Place your code here to do calculations/fill in fields
  Me.RecLocked = True
  Me.Dirty = False
  Me.AllowEdits = False
End Sub

Private Sub Form_Current()
  If Me.RecLocked Then
    Me.AllowEdits = False
  Else: Me.AllowEdits = True
  End If
End Sub
The record is now "locked" and can't be changed. If there's any chance you might have to redo your calculations, you need to add another button to your form, call it EditRec. Then add this code behind it:

Code:
Private Sub EditRec_Click()
  Me.AllowEdits = True
  Me.RecLocked = False
End Sub
This will "unlock" the record so you can redo your calculations. If you hit the edit button and change your mind about recalculating, just hit your button that does all this and it'll be redone using your original data and again "lock" the record from change.

Good Luck
 
Here's one way to do it, Jacks:

In your table add a field, datatype Yes/No
Set its Default to No

In the form's Design View place this field on the form
Name it RecLocked

Then place this code behind your form

Code:
Private Sub YourCommandButton_Click()
  'Place your code here to do calculations/fill in fields
  Me.RecLocked = True
  Me.Dirty = False
  Me.AllowEdits = False
End Sub

Private Sub Form_Current()
  If Me.RecLocked Then
    Me.AllowEdits = False
  Else: Me.AllowEdits = True
  End If
End Sub
The record is now "locked" and can't be changed. If there's any chance you might have to redo your calculations, you need to add another button to your form, call it EditRec. Then add this code behind it:

Code:
Private Sub EditRec_Click()
  Me.AllowEdits = True
  Me.RecLocked = False
End Sub
This will "unlock" the record so you can redo your calculations. If you hit the edit button and change your mind about recalculating, just hit your button that does all this and it'll be redone using your original data and again "lock" the record from change.

Good Luck

This works wonderfully !!

The trick is to use AllowEdits. The Me.Dirty thing I don't grasp yet, .. but I'll read the helpfiles on it. Thanks !!!
 
The record "lock" using AllowEdits = False won't take effect until the record is saved; that's what

Me.Dirty = False

does! It forces the saving of the record!
 
The record "lock" using AllowEdits = False won't take effect until the record is saved; that's what

Me.Dirty = False

does! It forces the saving of the record!

handy to know !! thanks !
 

Users who are viewing this thread

Back
Top Bottom