Friday, 23 August 2013

Create record and INSERT INTO with Constant field & Variable field data

Create record and INSERT INTO with Constant field & Variable field data

Within VBA, in Access 2003, I need to
Create a record in TableA with a new AutoNumber as the primary key (AID)
and the current date
Create several records in TableC which associate AID from the new record
in TableA with multiple foreign keys (BID) from TableB, as selected by
QueryB.
So if QueryB returns records from TableB with BIDs 2,5,7,8, I would then
like to create a record in TableA with AID = 1 and Date = 8/23/13
and then make TableC appear thusly:
AID, BID
1, 2
1, 5
1, 7
1, 8
How do I do this? I'm pretty sure I can write an SQL string to do the
first thing like so:
INSERT INTO TableA (Date)
VALUES Date()
but I'm not sure how to describe that I want to use the new record, (in
this case, AID = 1) to be the constant that all the QueryB records are
associated with.

No comments:

Post a Comment