Results 1 to 3 of 3
  1. #1
    tinapa29 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2016
    Posts
    2

    Merge Record from 3 Tables

    heres the code to query 4 tables (necessary to query all 4 tables)
    Code:
    SELECT * into tblDUPLICATE FROM ((CRIME LEFT JOIN SUSPECTS ON CRIME.CITE_NR = SUSPECTS.CITE_NR) LEFT JOIN OFFENSE ON CRIME.CITE_NR = 
    
    OFFENSE.CITE_NR) LEFT JOIN VICTIMS ON CRIME.CITE_NR = VICTIMS.CITE_NR WHERE (Year([DATE_COMTD])= YEAR(DATE());
    heres my code to


    MERGE record with the same CITE_NR AND NOT same V_NO
    WILL NOT MERGE if same CITE_NR AND SAME V_NO

    Code:
    Do Until BasRecSet.EOF
        Do Until rsMerge.EOF
            SQLScript01 = "SELECT * FROM " & STR4Query & " WHERE CITE_NR like " & Trim(rsMerge!CITE_NR)
            Set strBravo = CurrentDb.OpenRecordset(SQLScript01)
            With strBravo
                If BasRecSet.Updatable Then
                    If rsMerge!V_NO <> BasRecSet!V_NO Then
                        BasRecSet.Edit
                        BasRecSet!V_NAME = BasRecSet!V_NAME & ", " & BasRecSet!V_NAME
                        BasRecSet!V_SEX = BasRecSet!V_SEX & ", " & BasRecSet!V_SEX
                        BasRecSet!V_AGE = BasRecSet!V_AGE & ", " & BasRecSet!V_AGE
                        BasRecSet.Update
                    ElseIf rsMerge!S_NO  <> BasRecSet!S_NO  Then
                        BasRecSet.Edit
                        BasRecSet!S_NAME = BasRecSet!S_NAME & ", " & BasRecSet!S_NAME 
                        BasRecSet!S_SEX = BasRecSet!S_SEX & ", " & BasRecSet!S_SEX
                        BasRecSet!S_AGE = BasRecSet!S_AGE & ", " & BasRecSet!S_AGE
                        BasRecSet.Update                        
                    End If
                Else
                    MsgBox "Table Cannot Use for Updating!"
                End If          
            End With
        rsMerge.MoveNext
        Loop
    BasRecSet.MoveNext
    Loop
    but not performing the way i needed the code to

    as shown from the screenshots...

    Click image for larger version. 

Name:	final.jpg 
Views:	19 
Size:	70.4 KB 
ID:	26700

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    When you cross post, please tell readers you have done so and provide the associated link(s).

    Here is why!

    http://www.utteraccess.com/forum/ind...ic=2041008&hl=

  3. #3
    tinapa29 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2016
    Posts
    2
    Quote Originally Posted by RuralGuy View Post
    When you cross post, please tell readers you have done so and provide the associated link(s).

    Here is why!

    http://www.utteraccess.com/forum/ind...ic=2041008&hl=
    an honest mistake on my part since i'm really in dire need of help nonetheless, i apologize for the said incident...
    but would really appreciate if someone could provide me thanks....

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Merge Tables
    By cfobare79 in forum Access
    Replies: 21
    Last Post: 05-02-2015, 03:53 PM
  2. Replies: 1
    Last Post: 12-03-2014, 06:41 PM
  3. how to merge two or more tables horizontally with vba?
    By registoni in forum Programming
    Replies: 2
    Last Post: 09-20-2013, 06:43 AM
  4. Don't know if I should merge tables (please help)
    By bigdaddy757 in forum Database Design
    Replies: 2
    Last Post: 05-30-2013, 01:52 PM
  5. How do I Merge Four Tables Together
    By SteveI in forum Queries
    Replies: 1
    Last Post: 03-04-2010, 10:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums