• End of statement error (6?)

    Author
    Topic
    #374441

    I am converting an old Access database (2.0) to 2000.

    The conversion seemed to go well.
    I am having some problems with some of the forms.

    The old code goes like this:

    SQLString = “SELECT DISTINCTROW tblPurchaseOrderLineItems.* FROM ”
    SQLString = SQLString + “tblPurchaseOrderLineItems WHERE (tblPurchaseOrderLineItems.[PO#]=”
    SQLString = SQLString + Me![cmbPOGet]
    SQLString = SQLString + “) AND (tblPurchaseOrderLineItems.[LineItem#]=”
    SQLString = SQLString + Me![cmbLineItems]
    SQLString = SQLString + “);”

    The de###### tells me that the second line is bad.
    When I try to make it one line – like this:

    SQLString = “SELECT DISTINCTROW tblPurchaseOrderLineItems.* FROM ”
    SQLString = SQLString + “tblPurchaseOrderLineItems WHERE (tblPurchaseOrderLineItems.[PO#]= SQLString + Me![cmbPOGet] = SQLString + “) AND (tblPurchaseOrderLineItems.[LineItem#]= SQLString + Me![cmbLineItems] = SQLString + “);”

    The de###### says “Compile Error Expected End of statement” and it highlights the ).

    I have similar circumstances in a couple of forms.

    Any help will be appreciated.

    Thanks,
    Mark

    Viewing 0 reply threads
    Author
    Replies
    • #605699

      In the first group of statements, the problem I see is using the ‘+’.

      It’s not a good idea to use + for strings, it can cause problems like you found out. if you switch the ‘+’ to and ‘&’ things should work better.

      As for the second group, is the second and third lines all one line in the VBE?

      If it is, it should probably read:

      SQLString = SQLString & “tblPurchaseOrderLineItems WHERE (tblPurchaseOrderLineItems.[PO#]= ” & Me![cmbPOGet] & “) AND (tblPurchaseOrderLineItems.[LineItem#]= ” & Me![cmbLineItems] = & “);”

      • #605705

        Thank you for your help.

        Now it highlights the last & and says “Compile Error Expected; expression”

        Thanks again.

        Mark

        • #605716

          woopsMy mistake sorry , I left in an =

          the tail end should look like:

          Me![cmbLineItems] & “);”

    Viewing 0 reply threads
    Reply To: End of statement error (6?)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: