Access 2013

My OS is win 7 prof 64 bit and i use office 365 the home edition.  I have a small database created on Access 2013 which contains contact information.  From time some data fields get deleted whenever the cursor is resting in a field with the contents highlighted.  i would like to protect ALL the fields so that the data will not get deleted when such accidents take place, therefore i want to delete the data in a field only when I click on a command button to specifically to do so, and which will ask for confirmation, and if no confirmation is received within 5 seconds, then the transaction should be cancelled.  Can the experts please suggest how i can implement this feature in the most efficient way by way of code.  Thank u.
jegajothyretiredAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John TsioumprisSoftware & Systems EngineerCommented:
You should use transaction in order to have this kind of functionality...
On the Delete event you should have this kind of code
Also it will need some fiddling with the "On Timer" event in order to cancel after 5 seconds of inactivity...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PatHartmanCommented:
In the AfterUpdate event of each control, check for an empty field and prompt.
    If Me.SomeField & "" = "" Then
        If MsgBox("Are you sure you want to delete the contents of this field?",vbYesNo) = vbNo Then
            Me.SomeField.Undo
             Cancel = True
             Exit Sub
        End If
    End If

Open in new window

Access forms are already wrapped inside a transaction so you can't initiate another one.
Access won't let you save the record without responding to the validation code.
But, to be absolutely certain that required fields are not null, set their require property to yes in the table definition.
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Another alternative is to set the forms AllowEdits to false, or lock every control until a button is clicked, at which point you set AllowEdits to true or unlock the controls.

You can also use the BeforeUpdate event of the form to check controls and cancel the record save if you find certain fields are blank or have changed since the record was loaded.

All of these approaches have pluses and minuses to them.   What it comes down to how quickly you want to detect a problem, how much you want to get int he way of the users, and what the application/data is like.

For example, if they hop around on a form, some controls may need to be left blank for a moment, but can't be left blank to save the record.

In other cases, if a field already has a value, they may or may not be allowed to change it.

Jim.
0
jegajothyretiredAuthor Commented:
Thank u for a varied number of solutions.  Gracias.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.