Results 1 to 4 of 4

Thread: Help with concatrelated vba excel

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    Help with concatrelated vba excel

    Hi, I'm having problem using the function concatrelated on a sql statement. I want to obtain as follows:

    My data is:
    A.CABNRO E01.EXCCEX
    90001 500
    87000 400
    90001 450
    90001 300
    87000 500
    76005

    I want to obtain:
    A.CABNRO NEW FIELD
    90001 500,450,300
    87000 400,500
    76005

    The following code does not run when I include the statement related with concatrelated. I will be grateful if someone can help me!!!

    MYSQL = "SELECT A.CABFPR, A.CABCIA, A.CABCTR, B.CTRDTR, A.CABLOE, "
    MYSQL = MYSQL & "A.CABNRO, A.CABCAR, A.CABFED, A.CABHOD, A.CABFEI, "
    MYSQL = MYSQL & "A.CABHOI, A.CABFEF, A.CABHOF, A.CABFEE, A.CABHOE, "
    MYSQL = MYSQL & "A.CABCCL, A.CABNEM, A.CABDEM "
    MYSQL = MYSQL & "CONCATRELATED(EXCCEX, E01, A.CABNRO=E01.EXCNRO) "
    MYSQL = MYSQL & "FROM BDYOBEL.AIPDTA.AIPCAB A "
    MYSQL = MYSQL & "LEFT OUTER JOIN BDYOBEL.AIPDTA.AIPCTR B ON A.CABCIA=B.CTRCIA AND A.CABCTR=B.CTRCTR "
    MYSQL = MYSQL & "LEFT OUTER JOIN BDYOBEL.AIPDTA.AIPEXC E01 ON A.CABNRO=E01.EXCNRO "
    MYSQL = MYSQL & "WHERE A.CABCIA='LOR' AND A.CABFED>="
    MYSQL = MYSQL & Chr$(39) & fini & Chr$(39) & "AND A.CABFED<=" & Chr$(39) & ffin & Chr$(39)
    MYSQL = MYSQL & " AND (A.CABCTR='DM' OR A.CABCTR='L1' OR A.CABCTR='L5' OR A.CABCTR='LR') AND A.CABCAR<>'0'"


    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://www.youtube.com/watch?v=nVy4GAtkh7Q&lc=UgxJGNhWFZh2p5mK0XB4AaABAg. 9bbxud383FI9c-vOQApTgb
    https://www.youtube.com/watch?v=nVy4GAtkh7Q&lc=UgxJGNhWFZh2p5mK0XB4AaABAg. 9bbxud383FI9c-vbihZ-7W
    https://www.youtube.com/watch?v=nVy4GAtkh7Q&lc=UgxJGNhWFZh2p5mK0XB4AaABAg. 9bbxud383FI9c-vfmpSO0F
    https://www.youtube.com/watch?v=nVy4GAtkh7Q&lc=UgxJGNhWFZh2p5mK0XB4AaABAg. 9bbxud383FI9c-vjfTJ7lX
    https://www.youtube.com/watch?v=nVy4GAtkh7Q&lc=UgxJGNhWFZh2p5mK0XB4AaABAg. 9bbxud383FI9c-vmq-LHHz
    https://www.youtube.com/watch?v=nVy4GAtkh7Q&lc=UgxJGNhWFZh2p5mK0XB4AaABAg. 9bbxud383FI9c-vst3j_7i
    https://www.youtube.com/watch?v=nVy4GAtkh7Q&lc=UgxJGNhWFZh2p5mK0XB4AaABAg. 9bbxud383FI9bwBqjIR5Nj
    https://www.youtube.com/watch?v=nVy4GAtkh7Q&lc=UgxJGNhWFZh2p5mK0XB4AaABAg. 9bbxud383FI9bwBw8El0r5
    https://www.youtube.com/watch?v=nVy4GAtkh7Q&lc=UgxJGNhWFZh2p5mK0XB4AaABAg. 9bbxud383FI9bwC63GbRuM
    https://www.youtube.com/watch?v=nVy4GAtkh7Q&lc=UgxJGNhWFZh2p5mK0XB4AaABAg. 9bbxud383FI9bwC9fyKZdo
    https://www.youtube.com/watch?v=nVy4GAtkh7Q&lc=UgxJGNhWFZh2p5mK0XB4AaABAg. 9bbxud383FI9bwCEn8DBQe
    https://www.youtube.com/watch?v=nVy4GAtkh7Q&lc=UgxJGNhWFZh2p5mK0XB4AaABAg. 9bbxud383FI9bw0Bey8gQO
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 09-22-2023 at 05:37 PM.

  2. #2
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    12
    Last edited by snb; 10-18-2012 at 12:02 PM.

  3. #3
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  4. #4
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    As mentioned in a lot of other sources like Concatenation error: 'Undefined function 'ConcatRelated' in expression. including the origin of this function in Microsoft Access tips: Concatenate values from related records, have you tried saving the VBA function in a module with the database file?
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •