Hale, Jim
Jim.Hale at FleetPride.com
Thu Feb 10 15:03:56 CST 2005
It is possible to create the 24 records using SQL by doing a non Cartesian join. Create a table with one field. Create 48 one field records (this assumes that 48 is the max number you will be dealing with), the first record has the number 1, the second 2, etc. Create a query with this table where the criteria is set to <= the value of numports. Now create a query with the table (or query) that has your equipment record and the query you created above. Do not join the two tables/queries. When you run this query the result set will be 24 records because without a join every record in table/query A is "joined" to every record in table/query B. This result set can then be inserted into whatever table is desired. I have used this technique successfully to create event records for selected dates. Obviously it is only really viable for small tables (like yours) since joining every record in one table to every record in another table can quickly create a monster. A technique with perhaps limited use but it does have its place in the toolbox IMHO. Jim Hale -----Original Message----- From: John Clark [mailto:John.Clark at niagaracounty.com] Sent: Thursday, February 10, 2005 2:04 PM To: accessd at databaseadvisors.com Subject: [AccessD] Inserting a set amount of records into a table I have been whipping up a db to track our routers and switchs, and where they are wired to...eventually, I'd like to print a report that would be a wire map for a given piece of equipment. I've got it working pretty well, but I'd like to add one more thing before unveiling it. I have a form where each record is a separate piece of equipment, and a subform on this form, that will list all ports and where they go. Currently I have to enter 24 records for a 24 port switch and 48 records if it is a 48 port switch. I would like for it to automatically add 24 or 48 records, depending on the value in the numPorts field. I have never done anything like this before, but I am thinking that I will need some sort of FOR or DO WHILE loop that cycles through and INSERTS a record until it reaches the value of numPorts. Is this the gist of it? I really haven't worked with inserting records at all, so if there is anything I should know here, I'd appreciate it. Thanks John W Clark -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com *********************************************************************** The information transmitted is intended solely for the individual or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this email in error please contact the sender and delete the material from any computer. As a recipient of this email, you are responsible for screening its contents and the contents of any attachments for the presence of viruses. No liability is accepted for any damages caused by any virus transmitted by this email.