protect all data in form from editing (with override)

fau5tu5

Registered User.
Local time
Today, 02:58
Joined
May 10, 2009
Messages
24
I have a data entry form that has near 120 fields per form.

The form lets you view previously entries as well as "ADD a new entry".

I need to be able to in some way protect past entries from mistaken editing/overwriting.

In short to be able to lock all the info on a form, (single row in single table) but allow for a new entry to be input. All the fields on the new form need to be editable until they are finalized "saved". (so I cant simply put a lock on everything notNull or whatever)

I would prefer to do this with a couple buttons.

Ideally there would be:

1 (There is now) a "NEW" button that starts a new row and entry.

2. a "SAVE" record button that finalized and locks the row/entry

3. an "EDIT" button that lets you unlock a row to edit or correct later.


Keep in mind that I am still very new to access and VBA (unfortunately I have to squeeze in my learning without much time.)
I understand many of the concepts and logic of it and VB/VBA/SQL but lack much of the experience and functional knowledge.. So actual code, and better yet examples that I can take apart, emulate, study etc.. work much MUCH better than suggestions that refer to methods or verbage most of the experts here are as familiar with as breathing..
 
Set the form's Allow Edits property to NO and then if you wish to edit you could use a button to enable them:

Me.AllowEdits = True

and the reverse

Me.AllowEdits = False
 
Set the form's Allow Edits property to NO and then if you wish to edit you could use a button to enable them:

Me.AllowEdits = True

and the reverse

Me.AllowEdits = False


Ok.. I set two buttons and First off "THANK YOU" the "No Edits" (Me.AllowEdits = True) does lock it down..

AND allows for new entries and edits of those entries until it has been saved.

So.. With that I can get it funtional..

Question though..

When/if I hit the "Allow Edits" button, it does switch it to allow edits.. However, After I've done that it wont allow me to "No Edits" again. Which might be just fine depending on the the way I instruct users..

Is there something I havent done that would let me toggle between the two? (again not sure I want to the more I think about it,.. but from a learning perspective I would like to understand)

Also, where do I set the "Me.AllowEdits = False" as the DEFAULT for the form??? (as I think that will work well)
 
never mind on the "Where do I set the default" found it..

Sheeesh... and here i was looking all over for VBA code to protect the data and still allow new entries...

One toggle for the Allow edits default. (but the button will be a lifesaver,.. and thanks to SOS I understand a little better..

Thanks again
 
Actually, what you need to do to set the AllowEdits back to OFF if you have just set it to ON is to use:

If Me.Dirty Then Me.Dirty = False

to save the record first.
 
Ok... dont laugh.. but could you explain what the "Me.Dirty" means I have seen alot of use of the "Dirty" but I dont understand it...

Also can I add that to the "SAVE" button's function so that when you hit "SAVE" it also switches the AllowEdits back to False?
 
Ok... dont laugh.. but could you explain what the "Me.Dirty" means I have seen alot of use of the "Dirty" but I dont understand it...
When a form has some data change (either an edit or a field from a new record gets something in it) it makes the form "dirty" so-to-speak. So, we check to see if there is something to save and if so then setting the dirty equal to false means that it saves it.

Also can I add that to the "SAVE" button's function so that when you hit "SAVE" it also switches the AllowEdits back to False?
Just remember that a form does not need to have a save button. The record is automatically saved when you move off of it. However, if you want the save button then you can have it and then in the form's BEFORE UPDATE event you can validate whether to save or not depending on what happened or what fields have in them. You can issue a Cancel = True to the form's before update event to cancel the update if it fails your validation.

And yes, in the save button you can use

If Me.Dirty Then Me.Dirty = False

to start the save of the record (subject to it being canceled in the before update event of the form).

You can also use

DoCmd.RunCommand acCmdSaveRecord

but that always saves, even if nothing has changed, whereas the other one only does if something has "dirtied" the form.
 

Users who are viewing this thread

Back
Top Bottom