Results 1 to 2 of 2
  1. #1
    ritati is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Jan 2013
    Location
    Italy
    Posts
    1

    Compile error: Expected end of statement

    Hello,
    I'm trying to put a single command


    in several lines. The line of code is much wider than the
    editing screen. I'm putting underscore _ to separate lines
    of code. When I try this
    my code turns red and VBA tells me I have an
    error expected end of statement.
    Can someone please explain how this is done.
    code:
    DoCmd.RunSQL "INSERT INTO tblInventoryTransactions ([TransactionType],[ProdID], [Quantity],[PurchaseOrderID] )VALUES (" & 1 & ", " & ProductId.Value & "," & Quantity.Value & " , " & PurchaseID.Value & ");"

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    The underscore must be immediately preceded by a space and immediately followed by a line terminator (carriage return/enter key).
    Other option is
    Dim strSQL as String
    strSQL="your first line "
    strSQL=strSQL & "your next line " 'note space at the end of line
    strSQL=strSQL & "your next line "
    DoCmd.RunSQL strSQL

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Compile Error: Expected: list separator or )
    By jabadoojr in forum SQL Server
    Replies: 6
    Last Post: 10-22-2013, 01:55 PM
  2. Compile error: Expected: list separator or )
    By ThatWumboGuy in forum Programming
    Replies: 2
    Last Post: 08-03-2013, 10:33 PM
  3. Compile Error: Expected: list separator or )
    By Kirsti in forum Programming
    Replies: 2
    Last Post: 03-27-2012, 02:52 PM
  4. Replies: 6
    Last Post: 11-24-2011, 08:38 PM
  5. compile error: expected end of statement
    By RedGoneWILD in forum Programming
    Replies: 5
    Last Post: 07-29-2010, 10:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums