1VBAnewbie
Technical User
I need to update two tables using two forms. (Subform is not an option in this application)
On form1 the user enters data to create a record in table1. Upon the user moving to another record or leaving the form, I check for pre-existence of the record. Regardless of existence, I want form2 to open so a new record can be created in table2.
Form_BeforeUpdate() event on form1 is used to check for the existence of the record in table1.
Form_AfterUpdate() event on form1 is used to open form2.
If the BeforeUpdate event runs to conclusion when a record exists, I receive an error message (rightfully so) in attempting to create a record with an existing primary key.
If I cancel the BeforeUpdate event upon discovering the existing record, the AfterUpdate event does not execute. (this of course makes sense but doesn't help my cause)
These are my objectives:
1. after entry of data on Form1, determine if a record in table1 exists
2. update/insert the record in table1 only if record does not exist
3. open form2 regardless of existence of record in table1
I am seeking assistance with how to accomplish objectives 2 & 3.
On form1 the user enters data to create a record in table1. Upon the user moving to another record or leaving the form, I check for pre-existence of the record. Regardless of existence, I want form2 to open so a new record can be created in table2.
Form_BeforeUpdate() event on form1 is used to check for the existence of the record in table1.
Form_AfterUpdate() event on form1 is used to open form2.
If the BeforeUpdate event runs to conclusion when a record exists, I receive an error message (rightfully so) in attempting to create a record with an existing primary key.
If I cancel the BeforeUpdate event upon discovering the existing record, the AfterUpdate event does not execute. (this of course makes sense but doesn't help my cause)
These are my objectives:
1. after entry of data on Form1, determine if a record in table1 exists
2. update/insert the record in table1 only if record does not exist
3. open form2 regardless of existence of record in table1
I am seeking assistance with how to accomplish objectives 2 & 3.