Results 1 to 4 of 4

Queries in VBA

Threaded View

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Queries in VBA

    I have another problem with generating queries in code
    I get a SQL syntax error which I have narrowed down to the last addition to the SQL string (marked with*)
    Function SQLGumHist(StartD)
    strSQL = "SELECT "
    strSQL = strSQL & "WMSHIST.WM_INVOICE_DATE, WMSHIST.WM_STATUS, "
    strSQL = strSQL & "WMSTRAN.WT_NOMCC, WMSTRAN.WT_PRODUCT, WMSTRAN.WT_PRINT, "
    strSQL = strSQL & "WMSTRAN.WT_NET_TOTAL, WMSTRAN.WT_LENGTH, WMSTRAN.WT_WIDTH, WMSTRAN.WT_UNIT_PRICE "
    strSQL = strSQL & "FROM "
    strSQL = strSQL & "WINDMILL.WMSHIST WMSHIST, WINDMILL.WMSTRAN WMSTRAN "
    
    strSQL = strSQL & "WHERE "
    strSQL = strSQL & "WMSHIST.THIS_RECORD = WMSTRAN.PARENT_RECORD "
    strSQL = strSQL & "AND ((WMSHIST.WM_STATUS=18) AND (WMSTRAN.WT_NOMCC= ""GUM"" )) "
    *strSQL = strSQL & "AND ((WMSHIST.WM_INVOICE_DATE >= '" & Format(StartD, "yyyy-mm-dd") & "'"
    
    SQLGumHist = strSQL
    End Function
    I get confused with the quote marks and i expect theses are wrong, but I have not been able to see how.
    Can anyone help please
    John
    Last edited by j_Southern; 03-26-2012 at 10:24 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1