Results 1 to 3 of 3
  1. #1
    tmartin is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    37

    Receive Syntax Error in simple query. Looks good to me.

    I am unable to delete a record from a Table. I get an error


    "Syntax Error in query. Incomplete query clause"
    The value of SqlSyntax shown in the messagebox is

    DELETE FROM 'Daily Turn' WHERE DailyTurnID = 4796

    I do not see anything wrong with this query. There is a relationship to two other
    tables but the "Enforce ..." not not selected. Any ideas?



    Dim tblName As String
    tblName = "Daily Turn"
    Const cstrPrompt As String = _
    "Are you sure you want to delete this record? Yes/No"

    If MsgBox(cstrPrompt, vbQuestion + vbYesNo) = vbYes Then
    MsgBox "DailyTurnID = " & Me.DailyTurnID
    SqlSyntax = "DELETE FROM '" & tblName & "' WHERE DailyTurnID = " & Me.DailyTurnID
    MsgBox SqlSyntax
    CurrentDb.Execute SqlSyntax
    Call btnReturn_Click
    Else 'user clicked no
    MsgBox "Deletion was aborted.", vbInformation
    End If

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    Replace the apostrophes with []. Use [] to delimit object names that have spaces and special characters/punctuation (underscore is exception) or are reserved words. Recommend avoiding those in naming convention.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    I do not see anything wrong with this query. There is a relationship to two other
    tables but the "Enforce ..." not not selected. Any ideas?
    Here's a link to Access SQL that may help

    You should also use code tags when showing/posting any code.
    Highlight the code then click on the # above this posting window.

    Good luck with your project.
    Last edited by June7; 05-09-2015 at 05:34 PM.

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

Similar Threads

  1. Replies: 2
    Last Post: 09-10-2014, 11:30 AM
  2. Replies: 11
    Last Post: 05-01-2014, 11:56 AM
  3. Query Error 3075 Syntax Error
    By jbailey4545 in forum Queries
    Replies: 8
    Last Post: 03-11-2014, 01:34 PM
  4. Replies: 3
    Last Post: 03-05-2013, 11:17 AM
  5. Replies: 6
    Last Post: 05-30-2012, 12:32 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