Results 1 to 6 of 6
  1. #1
    SamNotSoWise is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    4

    Expected End of Statement error

    Hi

    I'm getting an Expected End of Statement error on the second RunSQL statement shown below. I broke these apart for troubleshooting. The first statement runs fine using Integer data. The second statement, which is String data, does not run. I have not been able to find anything on-line so far to correct this error.



    Also, I would like to combine these into a single statement and would appreciate suggestions for syntax.

    Dim vlast, vLotID
    vlast = Me.Last 'Last is integer
    vLotID = Me.LotID 'LotID is string

    DoCmd.RunSQL "UPDATE tblMachines SET tblMachines.LastNo =" & vlast & " WHERE MachineID = '" & Me.MachID & "'"
    DoCmd.RunSQL "UPDATE tblMachines SET tblMachines.LastLotID = '" & vLotID & "'" WHERE MachineID = '" & Me.MachID & "'"

    Many thanks!

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Too many quotes. Try

    DoCmd.RunSQL "UPDATE tblMachines SET tblMachines.LastLotID = '" & vLotID & "' WHERE MachineID = '" & Me.MachID & "'"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    SamNotSoWise is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    4
    Works like a charm - thanks!

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    I don't do a lot of this, but doesn't there need to be a closing semi-colon (;) at the end of the SQL statement?

    Linq ;0)>

  5. #5
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Quote Originally Posted by Missinglinq View Post
    I don't do a lot of this, but doesn't there need to be a closing semi-colon (;) at the end of the SQL statement?

    Linq ;0)>
    No, there doesn't.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    As I said, I don't do a lot of this kind of thing; just never had the occasion! But I do try to learn something new, everyday, and this is it for today!

    Thanks, Paul!

    Linq ;0)>

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

Similar Threads

  1. Runtime Error 3061 Expected 3
    By kumail123 in forum Programming
    Replies: 1
    Last Post: 03-28-2012, 09:44 AM
  2. 3061 Error. Too few parameters. Expected 1.
    By rghollenbeck in forum Queries
    Replies: 5
    Last Post: 09-28-2011, 12:12 PM
  3. compile error: expected end of statement
    By RedGoneWILD in forum Programming
    Replies: 5
    Last Post: 07-29-2010, 10:12 AM
  4. Replies: 3
    Last Post: 07-21-2010, 02:41 AM
  5. Syntax Error while calling sub: Expected: =
    By cowboy in forum Programming
    Replies: 3
    Last Post: 07-12-2010, 02:21 PM

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