Missing Operator syntax error is SQL VB code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • g_k_harrison@yahoo.com

    Missing Operator syntax error is SQL VB code

    Hi. I have a button - Command9 with the Click event to run this code
    on a form called frmSelforDel.

    Dim SQL1 As String
    DoCmd.SetWarnin gs False
    SQL1 = "DELETE FROM 260Land WHERE 260ID = txtDel.Value"

    On that same form is a text box named txtDel with a set value. 260Land
    is a table with 260ID as a column.

    I'm not knowledgeable enough to get the syntax correct on this
    statement. Please help. Thank you!

    Greg.
  • DFS

    #2
    Re: Missing Operator syntax error is SQL VB code

    g_k_harrison@ya hoo.com wrote:
    Hi. I have a button - Command9 with the Click event to run this code
    on a form called frmSelforDel.
    >
    Dim SQL1 As String
    DoCmd.SetWarnin gs False
    SQL1 = "DELETE FROM 260Land WHERE 260ID = txtDel.Value"
    >
    On that same form is a text box named txtDel with a set value. 260Land
    is a table with 260ID as a column.
    >
    I'm not knowledgeable enough to get the syntax correct on this
    statement. Please help. Thank you!
    >
    Greg.
    Dim db as DAO.Database, strSQL as String
    Set db = currentDb()
    db.Execute("DEL ETE FROM 260Land WHERE [260ID] = '" & Me.txtDel.Value & "';")

    Without bracketing the column name, the '260' prefixes may give you
    problems.

    No offense, but 260Land is a strange name for a table. What's in it?


    Comment

    • Salad

      #3
      Re: Missing Operator syntax error is SQL VB code

      DFS wrote:
      g_k_harrison@ya hoo.com wrote:
      >
      >>Hi. I have a button - Command9 with the Click event to run this code
      >>on a form called frmSelforDel.
      >>
      >>Dim SQL1 As String
      >>DoCmd.SetWarn ings False
      >>SQL1 = "DELETE FROM 260Land WHERE 260ID = txtDel.Value"
      >>
      >>On that same form is a text box named txtDel with a set value. 260Land
      >>is a table with 260ID as a column.
      >>
      >>I'm not knowledgeable enough to get the syntax correct on this
      >>statement. Please help. Thank you!
      >>
      >>Greg.
      >
      >
      Dim db as DAO.Database, strSQL as String
      Set db = currentDb()
      db.Execute("DEL ETE FROM 260Land WHERE [260ID] = '" & Me.txtDel.Value & "';")
      >
      Without bracketing the column name, the '260' prefixes may give you
      problems.
      >
      No offense, but 260Land is a strange name for a table. What's in it?
      >
      >
      To the original poster, you need to remember dates are surrounded by #,
      strings by quotes, and numbers by themselves

      txtDel = "YourName"
      ? "WHERE [260ID] = '" & txtDel & "';"
      WHERE [260ID] = 'YourName';
      ? "WHERE [260ID] = """ & txtDel & """;"
      WHERE [260ID] = "YourName";

      txtDel = Date()
      ? "WHERE [260ID] = #" & txtDel & "#;"
      WHERE [260ID] = #4/5/2008#;

      txtDel = 123
      ? "WHERE [260ID] = " & txtDel & ";"
      WHERE [260ID] = 123;

      IceCube

      Comment

      • g_k_harrison@yahoo.com

        #4
        Re: Missing Operator syntax error is SQL VB code

        On Apr 4, 11:05 pm, "DFS" <nospam@dfs_.co mwrote:
        g_k_harri...@ya hoo.com wrote:
        Hi. I have a button - Command9 with the Click event to run this code
        on a form called frmSelforDel.
        >
        Dim SQL1  As String
        DoCmd.SetWarnin gs False
        SQL1 = "DELETE FROM 260Land WHERE 260ID = txtDel.Value"
        >
        On that same form is a text box named txtDel with a set value. 260Land
        is a table with 260ID as a column.
        >
        I'm not knowledgeable enough to get the syntax correct on this
        statement. Please help. Thank you!
        >
        Greg.
        >
        Dim db as DAO.Database, strSQL as String
        Set db = currentDb()
        db.Execute("DEL ETE FROM 260Land WHERE [260ID] = '" & Me.txtDel.Value & "';")
        >
        Without bracketing the column name, the '260' prefixes may give you
        problems.
        >
        No offense, but 260Land is a strange name for a table.  What's in it?
        Thanks very much! Yes, the number preceding ID was definitely a
        problem. 260Land is a section of a form that's the basis for this
        database and covers land cost, surveying insurance, etc... I
        appreciate your help greatly!

        Comment

        Working...