Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts

    sql concatenation

    Error in SQL concatenation


    I have built the followign code :


    Dim SQLCustomerOrder As String
    Dim SQLAfid As String
    Dim SQLBas As String
    SQLAfid = "AND ((Customers.afid)=1)"
    SQLBas = " SELECT DISTINCT Customers.*, orders.paymentid, Customers.afid FROM Customers INNER JOIN orders ON (Customers.Customerid = orders.customerid) AND (Customers.Customerid = orders.customerid) WHERE (((orders.paymentid)=0) );"
    SQLCustomerOrder = SQLBas & SQLAfid
    Me.RecordSource = SQLCustomerOrder


    i have tried to divide a valid sql clasue into two parts, but i failed to do it
    and i receive the meesage "Characters found after end of sql clause".

    The original and valid sql query was as follows

    SELECT DISTINCT Customers.*, orders.paymentid, Customers.afid
    FROM Customers INNER JOIN orders ON (Customers.Customerid = orders.customerid) AND (Customers.Customerid = orders.customerid)
    WHERE (((orders.paymentid)=0) AND ((Customers.afid)=1));

    It seems i cannot take out the And clause in the rigth way.

    ANy help?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: sql concatenation

    Your problem is the semicolon at the end of your SQLBas expression. To the query engine, that signals the end of the SQL. Then you concatenate another phrase to it and you get the error. If you remove the semicolon, it should work, although I don't see why you have two joins on the same combination of fields in either query. You should be able to remove one of them.
    Charlotte

Posting Permissions

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