Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating Tables from a Form

Status
Not open for further replies.

jrtaylor

Technical User
Jan 24, 2002
34
US
I have a database where there is the same key field in most of the tables. I have a form where a new record for the key field is added. How can I automatically have all the tables updated when a new record is added to the key field without bringing all the tables into the query of the form adding the new key record?

The reason is because when I go to the other forms in my database they are not picking up the new record added to the key field and therefore do not appear in the combo box for selection.

Thanks,
jrtaylor[flowerface]
 
As far as my knowleged
U can do it at Form_afterInsert event
U get teh value of Key and run the Update Queries
if that is a bound Form

For UnBound Forms we must have no problems there
 
So what you are saying is I create another query which is an update query different from the query creating the form. This update query updates all the other tables. How do I get the query to run on the Form_afterInsert?
 
Dim StrSQL as String
StrSQL = &quot;Update <TableName> Set <Field1Name> = &quot; & Me.<Contorl1Value> & &quot;,<Field2Name> = &quot; & Me.<Contorl2Value>
& &quot; where <FieldNName> = &quot; & Me.<ControlNValue>
Currentdb.Execute StrSQl
We can Repeat
<FieldxName> = &quot; & Me.<ContorlxName>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top