Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    May 2001
    Location
    New Jersey, USA
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts

    End of statement error (6?)

    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

  2. #2
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: End of statement error (6?)

    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] = & ");"
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  3. #3
    Star Lounger
    Join Date
    May 2001
    Location
    New Jersey, USA
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: End of statement error (6?)

    Thank you for your help.

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

    Thanks again.

    Mark

  4. #4
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: End of statement error (6?)

    <img src=/S/woops.gif border=0 alt=woops width=58 height=36>My mistake <img src=/S/sorry.gif border=0 alt=sorry width=15 height=15> , I left in an =

    the tail end should look like:

    Me![cmbLineItems] & ");"
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

Posting Permissions

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