Add new records from a filtered query (1 Viewer)

Dumferling

Member
Local time
Today, 13:05
Joined
Apr 28, 2020
Messages
102
I am not sure how I go about this. I have contracts which are listed in one table (Contracts). A contract can be affected by different regulations, depending on the industry (lets say Insurance) So, I have a related table (Regulations) on which I want to list the different regulations for each Insurance contract. Every time a new contract is added, I need to go to a third table (RegulationSource), filter the list by Insurance and add each regulation to the Regulations table.

How do I get Access to look at a filtered set of records, pick up each one and add them to the table? The adding I can do (AddNew) but how do I get to look at a filtered set of records and scroll through each one until the end of the recordset? It's not something I have ever done before.
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:05
Joined
Sep 21, 2011
Messages
14,238
If it is in form use the recordsetclone property.
If in a listbox, walk through it's recordsource.
Then probably use an insert query to add the records?

arnelgp has just posted an example using recordsetclone.

Try searching for that.

Here it is, as I do not think the search looks in code tags :(
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:05
Joined
Feb 19, 2002
Messages
43,233
If your tables are correctly defined, there is no need to copy anything. Please post a database with some data so we can see how you are trying to tie things together. The Contract table needs an IndustryCD field and the Regulation table also needs an IndustryCD. A third table is used to define valid Industries. Contract is joined to Regulation on IndustryCD to return all the regulations that apply to that contract.

Regulations should not be changed. They should be marked with an expiration date and then be replaced with a new version. The query that joins Contracts and Regulations can bring back only active regulations or all regulations including expired or future regulations depending on how you want to use the query's recordset.
 

Users who are viewing this thread

Top Bottom