Solved

Loop and combine records from two tables into third table

Posted on 2013-01-17
2
418 Views
Last Modified: 2013-01-17
I have a form with two multi-select list boxes.
1. list box contains months (recordset = tmpInvoiceMth)
2.  list box contains years (recordset = tmpInvoiceYr)

Once the user has chosen their corresponding months and years I would like to loop through both recordsets and add the corresponding Mth-Yr combination into a third recordset (tmpInvoiceMthYr)

EX:  User chooses Jan and Feb from list box 1 and  2012 and 2013 from list box 2
after looping tmpInvoiceMthYr should contain the following records

Jan 2012
Feb 2012
Jan 2013
Feb 2013

Thanks as always for your assistance

~Worcse
0
Comment
Question by:Worcse
2 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 300 total points
ID: 38789266
dim j, i
rs as dao.recordset

set rs=currentdb.openrecordset("tmpInvoiceMthYr")
for each j in me.listMonth.itemsselected

      for each i in me.listYear.itemsselected
            with rs
                 .addnew
                 !MonthYear=me.listMonth.itemdata(j) & " " & me.listYear.itemdata(i)
                 .update
             end with

      next i
next j
0
 

Author Comment

by:Worcse
ID: 38789452
Cap - spot on as always
Well done sir...!
Thank you for your assistance.
~Worcse

I have attached the code which is now working for me
tmpInvoiceMthYr.doc
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question