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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating record in related tables 1

Status
Not open for further replies.

Moss100

Technical User
Aug 10, 2004
579
0
16
GB
Hello,

I have a table called properties.

This has related tables called

Rooms
And
Fittings

When I add a new record in properties I would like to create a record in each of the other tables.

What is the best way to achieve this?

Many thanks mark.
 
Try use code in the after insert event of the form bound to the properties table. It might look something like:

Code:
Dim strSQL as String
strSQL = "INSERT INTO ROOMS (foreignkeyfield) Values(" & me.primarykeyfield & ")"
Currentdb.execute strSQL, dbFailOnError
strSQL = "INSERT INTO FITTINGS (foreignkeyfield) Values(" & me.primarykeyfield & ")"
Currentdb.execute strSQL, dbFailOnError



Duane
Hook'D on Access
MS Access MVP
 
If dhookom’a post was helpful, click on: [blue]Like this post? Star it[/blue].
This indicates the post answered your question and marks it for other to see the solution.


Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top