Prevent Record Creation Upon Form Exit

Earl C Phillips

Volunteer Programmer
Local time
Yesterday, 21:29
Joined
Jul 18, 2008
Messages
40
:confused:I run Access 2007, VBA, and try to create a record upon pressing the "add record" button with appropriate edits. I try to prevent record creation at any other time, like exiting the form. I am currently using Me.Undo to clear the screen and DoCmd.CancelEvent to try to prevent record creation by any other action except the "add record" button.

Still, records are created, often duplication records and occasionally creating incomplete records. How do I reliably prevent record creation except when using the "add record" button?
 
As there are no other replies
would this work?

create a global vairable, call it what you want but here I'll call it gvariable

when you press the add button have this code as the first line of code
gvariable = "1"

On each of your sub routines have as the first few lines

if gvariabale <> "1" then
exit sub
end if


which ever is the last routine to run when a record is added, add this as the last line
gvariabale ="0"


smiler44
 
Still no solution. I tried setting up multi-field keys and that has worked for some of the problems. There is one table that has participant name as part of the key and it is frequently left blank by the participants. This allows multiple records without data to be entered with the same blank key. I have tried to set up referential integrity between tables, but the choice is grayed out when I try to set up the connection. I have used queries, etc to prove that there is no problem with orphan entries, but the choices are still grayed out. How can I establish connections between tables after there are records in the tables?:banghead:
 

Users who are viewing this thread

Back
Top Bottom