Preventing users from overwriting existing data

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

Guest

Thanks in advance for any advice you can give me on this...
I have a problem with users trying to find records (using a single form
view): they always seem to "forget" to click find or ctrl+F before entering
their criteria, therefore they are overwriting existing records. The users
do need to be able to make changes to these existing records, so I can't just
change the form to read only or data entry. I probably only need to
"protect" 2 fields at the most (PONUMBER and JOBNUMBER).
Could someone point me in the right direction as far as a fix?
Thanks again.
 
You can set the properties for those two fields so that the users can't
update them.
Change Tab Stop to NO and Locked to Yes for those two fields.

As for the rest of the form.... when the user needs to be able to update once
in awhile, there is more work involved to prevent unwanted updates. The easy
way is to set your form to cycle the single record and force the user to
click on a Next Record button.... but, if they don't pay attention now........
....
 
I'm sorry, I guess I should have been more clear...the users do need to be
able to write to these fields when the field value is null. I want to be
able to keep them from changing the values once they've been assigned.

Thanks again.
 
I assume that PONUMBER and JOBNUMBER are key fields that should never be
changed once created. If this is the case, you will need a little code in a
couple of places.
In the Form's Current event, check to see if it is a new record, and if it
is, unlock the controls for those fields, otherwise lock them.

Me.txtPoNumber.Locked = Not Me.NewRecord
Me.txtJobNumber.Locked = Not Me.NewRecord

The other place may be the Form's After Update event where you would lock
them. Depending on how your form navigation is structured, you may not need
to do this.

Me.txtPoNumber.Locked = True
Me.txtJobNumber.Locked = True
 
Thanks in advance for any advice you can give me on this...
I have a problem with users trying to find records (using a single form
view): they always seem to "forget" to click find or ctrl+F before entering
their criteria, therefore they are overwriting existing records. The users
do need to be able to make changes to these existing records, so I can't just
change the form to read only or data entry. I probably only need to
"protect" 2 fields at the most (PONUMBER and JOBNUMBER).
Could someone point me in the right direction as far as a fix?
Thanks again.

Simplest would be to set the Allow Updates property of the Form to No;
if you leave the Allow Additions set to Yes, the user will be able to
add new data but not overwrite existing fields at all.

If you do so you'll want to have some provision - perhaps a command
button - to open a record for editing, if the user needs to correct or
update previously entered data. This button can just set the Allow
Edits property to Yes; set it back to No in the form's Current event.

John W. Vinson[MVP]
 
John Vinson's solution sounds like it should resolve your issue.

Gina said:
I'm sorry, I guess I should have been more clear...the users do need to be
able to write to these fields when the field value is null. I want to be
able to keep them from changing the values once they've been assigned.

Thanks again.
You can set the properties for those two fields so that the users can't
update them.
[quoted text clipped - 15 lines]
 
John,
I've been looking for an answer to this same issue for a long time. How
do I enter the code for the command button to set Allow Edits to Yes? I
assume that I would add a command button and enter the code for the On
Click event. Once the user clicks that button to edit the record, how
does the form go back to being "protected"?
Thanks,
Darrell
 
Hi,

You can change the control in the procedure handling the onCurrent
event. There, you can Lock the control if its value is not NULL, and unlock
it otherwise.

Me.ControlName.Locked = IsNull(Me.ControlName.Value)


Hoping it may help,
Vanderghast, Access MVP
 
I am new to this but this answer sounds like exactly what i need. I am too
attempting to prevent overwritting data when the field is not null however i
am not sure how to or where to plug in the suggested code below. Can you
please help a true beginner? thanks ART
 
Back
Top