Insert into data into two tables from one insert form
Not sure if this is possible.
I have a many to many relationship for attaching Users to Agents (Companies). I'm using a Users table, an Agents table, and an interlinking table:
Users
UserID (PK)
AgentID
Firstname
Lastname
etc
Agents:
AgentID (PK)
Company
etc
Agent_Users
AUID (PK)
UserIDIT
AgentIDIT
Currently adding a new user, and associating it with an agent is a two step process.
1. Create the new user (but from a page for the Agency, allowing me to at least store the correct AgentID value in the Users table)
2. Insert UserIDIT and AgentIDIT into the Agent_Users table.
My question is, is it possible at all to do this in one step?
It would just need to both;
1. Insert the new record into the Users table
2. Insert the UserID of the newly created user plus the AgentID of the company into the Agent_Users table as UserIDIT and AgentIDIT
Hope I've explained that well enough?
Thanks.