Advertisement

07.07.2008 at 04:35PM PDT, ID: 23545098
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.6

MS ACCESS VBA - compare 2 recordsets for matching fields then add some data from each record to a new record in another table

Asked by Aljeebo in VB Database Programming, Access Coding/Macros

Tags:

Hi folks

I have 2 tables, parent categories and child categories relating to products for an online shop.

Parent Categories Table fields
*Cat_id    cat_name

Child Categories Table fields
Cat_id    *parent_cat_id    cat_name

My problem is that the only information that the child categories table has about the parent categories is an ID, so parent_cat_id in the child categories table links to the cat_id field in the parent categories table.

Parent cat table = 42 records and child = 120.

I need to loop through both recordsets and where the IDs match grab cat_name from both tables and concatenate them into a full category name field in my new table (which is already created, doesn't need be created dynamically or anything).

the code I have so far:

Public Sub NameCategories()

Dim db As Database
Dim rc_parent As Recordset
Dim rc_child As Recordset
Dim rc_CategoriesComplete As Recordset
Dim parent_name As String

Set db = CurrentDb()
Set rc_parent = db.OpenRecordset("parent")
Set rc_child = db.OpenRecordset("child")
Set rc_CategoriesComplete = db.OpenRecordset("CategoriesComplete")

rc_parent.MoveFirst
rc_child.MoveFirst

Do While Not rc_child.EOF

    If rc_parent![cat_id] = rc_child![parent_cat_id] Then
   
        rc_CategoriesComplete.AddNew
        rc_CategoriesComplete![parent_cat_id] = rc_parent![cat_id]
        rc_CategoriesComplete![child_cat_id] = rc_child![cat_id]
        rc_CategoriesComplete![cat_string] = rc_parent![cat_name] + "/" + rc_child![cat_name]
        rc_CategoriesComplete.Update
        rc_child.MoveNext
       
    Else
         
        rc_parent.MoveNext
       
    End If

        rc_parent.MoveFirst
   
Loop
   
End Sub

...sorry, I know it's not moving correctly. to be honest I've been messing with it so much I'm lost now!

Can you please help?

Many thanks

AlStart Free Trial
[+][-]07.07.2008 at 05:10PM PDT, ID: 21949718

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.08.2008 at 12:51AM PDT, ID: 21951736

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.08.2008 at 05:01AM PDT, ID: 21952854

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: VB Database Programming, Access Coding/Macros
Tags: VBA
Sign Up Now!
Solution Provided By: capricorn1
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.12.2008 at 12:49AM PDT, ID: 21988073

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628