Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Loop and combine records from two tables into third table

Posted on 2013-01-17
2
Medium Priority
?
433 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1200 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Starting up a Project
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 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