Table data entry prevention

iamdamien

Registered User.
Local time
Today, 21:11
Joined
Apr 18, 2011
Messages
25
I am using forms to input data into tables, just wondered if there was a way to prevent data entry into the tables so that the data is only added once a user presses the "save" button?
is this possible?
Not a major issue if not, just want to prevent the entry of incomplete records.
 
you should use the forms beforeupdate event to check whether all fields have been completed correctly, and cancel the update if not.

you can set "required" to true, or use some other validation on some fields, at table level to help with this maybe. Sometimes this can't be done with these simple methods because of the way your app works.
 
One thing you can do is to look at the form properties: AllowAddition, AllowEdit, etc. They govern what can be done on the form using standard Access navigation. If you disallow addition, then the ONLY way you can add data is through a command button that does a Save action for you. HINT: The button wizard has an option to do exactly that, because I've used it. You also need to consider something that checks for the form being "dirty" (a form property but only of bound forms), because in that case you can also turn off the navigation on the form (temporarily). That way, you will have not way on the form to save anything by navigation. WARNING: You need event traps on the Close event, BeforeUpdate event, and a few others. What I do is have a Boolean variable in the declaration area of the form's class module. I set that flag if someone has clicked the SAVE button because the CLICK event first first. Inside the click event I have code to do the actual save, so I have time to toggle that flag.

When the BeforeUpdate event fires, it can see the flag I set and allow the update. If someone tries to use any other method including closing the form, you can block that by returning a CANCEL=TRUE on whatever event fires when that flag is NOT set.
 

Users who are viewing this thread

Back
Top Bottom