Results 1 to 6 of 6

Thread: vba issue with inner join

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2012
    Posts
    23

    vba issue with inner join

    Hello I'm trying to connect to my db using an inner join
    Code:
    str = "SELECT CCSMS.CUST_NO " _
        & "FROM CSPCL INNER JOIN CCSMS " _
        & "ON CCSMS.CUST_NO = CSPCL.CUST_NO "
    I keep getting the error Name:  Capture.PNG
Views: 254
Size:  8.3 KB

    thanks,
    JO

  2. #2
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: vba issue with inner join

    I've never seen that error before so I googled it. I get loads of results where people are experiencing it in various prorprietary systems and databases. What database are you using? What data provider are you using? Are you getting this form a prorprietary app or your own VB app? And what's the code you're using to post that query to the database.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2012
    Posts
    23

    Re: vba issue with inner join

    Hey thanks for the reply. The if I change it to a where it works fine. I am just trying to speed it up a bit
    1. NGS
    2. MSGDASQL
    3. Mine
    4.
    Code:
     Set cnt = New ADODB.Connection
     Set rst = New ADODB.Recordset
    
      str = "SELECT CCSMS.CUST_NO " _
        & "FROM CSPCL INNER JOIN CCSMS " _
        & "ON CCSMS.CUST_NO = CSPCL.CUST_NO "
        
        rst.Open str, cnt
        LstCnt = 1
        Do Until rst.EOF
            LstCnt = LstCnt + 1
            rst.MoveNext
        Loop
        rst.Close
        ReDim InfoArray(LstCnt, 6)
        rst.Open str, cnt
        X = 0
        
        Do Until rst.EOF
            InfoArray(X, 0) = rst!CUST_NO
            InfoArray(X, 1) = rst!CUST_SITE
            InfoArray(X, 2) = rst!SITE_NAME
            InfoArray(X, 3) = rst!CUS_SITE_ADDR_1
            InfoArray(X, 4) = rst!CUST_ADDR_1
            InfoArray(X, 5) = rst!CUST_ADDR_3
            X = X + 1
            rst.MoveNext
        Loop

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: vba issue with inner join

    Try simply removing the word Inner, as most/all database systems treat a Join without any extra keywords as an Inner join.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Sep 2012
    Posts
    23

    Re: vba issue with inner join

    When I remove inner
    Name:  Capture.PNG
Views: 128
Size:  5.9 KB

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: vba issue with inner join

    OK, well try the really simplified version:
    Code:
      str = "SELECT CCSMS.CUST_NO " _
        & "FROM CSPCL, CCSMS " _
        & "WHERE CCSMS.CUST_NO = CSPCL.CUST_NO "

Posting Permissions

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



Click Here to Expand Forum to Full Width