Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2006
    Posts
    2

    Unanswered: Left Joins with Multiple Conditions in VBA

    Hello,

    I am trying to run a query in Excel VBA. The query has a left join with a two conditions -- every time I run it excel crashes. If I remove the brackets enclosing the two conditions, the query fails.

    The query itself is correct because if I run it directly in Oracle it works. Also I can run it thru excel via Date->Import External Data but not thru VBA.

    Also if I restrict myself to one condition instead of two it works thru VBA.

    Any one have any insights into what the problem could be?? Or any proposed workaround... Thanks in advance.

    Saleem


    Dim db As Database

    Set db = OpenDatabase("", dbDriverPrompt, False, "ODBC;DSN=FM;")

    Query = "select VCI.isec_id, VCI.inst_class, CVL_IDENT_BB.EXT_IDENT, VCI.pl_ccy as CCY " _
    & "from V_CONT_INMK VCI " _
    & "left join IDENTIFIER CVL_IDENT_BB on (CVL_IDENT_BB.tdp_id = VCI.isec_id and " _
    & "CVL_IDENT_BB.ident_type = " & Chr(39) & "BB_TCM" & Chr(39) & ") " _
    & "where VCI.inst_class in (" & Chr(39) & "ORD" & Chr(39) & ", " & Chr(39) & "DR" & Chr(39) & ", " & Chr(39) & "CFD" & Chr(39) & ")"

    Dim FM As Recordset

    Set FM = db.OpenRecordset(Query, dbOpenDynaset, dbSeeChanges, dbReadOnly)

  2. #2
    Join Date
    Mar 2006
    Posts
    163
    Are you sure Query is getting the correct SQL?

  3. #3
    Join Date
    Apr 2006
    Posts
    2

    Left Join Problem

    Yes. I actually forced the function to return the query and cut and paste it into Oracle and it works!!

    Saleem

Posting Permissions

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