Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2014
    Posts
    6

    Question Unanswered: SQL Delete From problem

    Thanks to all that responded. It is fixed.
    _______________________

    I have an Access front end and SQL back end. I have the following code in my program :

    DoCmd.RunSQL "Delete From [dbo_dbAccess] Where userId = & lclUserId & "

    When I run the program I get the following error message:

    Run-time error '3075":
    Syntax error (missing operator) in query expression 'userId = & lclUserId &'

    I'm sure it is a very simple answer, but am new to SQL server and VBA coding.

    Thanks to all that responded. It is fixed.
    Last edited by sclark1955; 05-07-14 at 13:15.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Try:
    Code:
    DoCmd.RunSQL "Delete From dbo_dbAccess Where userId = " & lclUserId
    This supposes that userId is numeric. If it's text, use:
    Code:
    DoCmd.RunSQL "Delete From dbo_dbAccess Where userId = '" & lclUserId & "'"
    Note: You dont need to write the name of the table between square brackets as it does not contain special characters or spaces and it is not a reserved word.
    Have a nice day!

  3. #3
    Join Date
    Feb 2014
    Posts
    6

    Thank you

    That did it. Looks like I need to brush up on my VBA punctuation/

  4. #4
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    495
    Provided Answers: 24
    yes, only Text values need surrounded by quotes. Numbers dont.

  5. #5
    Join Date
    Feb 2014
    Posts
    6

    Thank you

    Thanks. It is fixed.

  6. #6
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Tags for this Thread

Posting Permissions

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