Results 1 to 5 of 5

Thread: Delete SQL qry Syntax

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    2

    Question Delete SQL qry Syntax

    I get a '3219' (Monsters Inc?) runtime error on opening the following SQL VB6 string. It connects to Access 2003 MDB.

    strSQL = "DELETE tblA01.* " _
    & "From tblA01 " _
    & "WHERE ((tblA01.Bin)=(SELECT tblSSE.BIN " _
    & "FROM tblSSE));"

    Set rstFDtable = ATLAS.OpenRecordset(strSQL, dbOpenDynaset, dbConsistent, dbOptimistic)


    Debug.print result:-

    DELETE tblA01.* From tblA01 WHERE ((tblA01.Bin)=(SELECT tblSSE.BIN FROM tblSSE));

    Error occurs on execution of Set command. I'm sure it is a syntax prob. but can I find it ..... aghh!

    Any help appreciated. Thanks TC

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Delete SQL qry Syntax

    Only Select statements can be used to open a recordset. Action queries do not require a recordset. You can use connection objects execute method to execute the delete statement.

    Also your query will not work. Instead of using = in the where condition use In.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    2

    Re: Delete SQL qry Syntax

    Thankyou. That's a fundamental aspect I never knew.

  4. #4
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: Delete SQL qry Syntax

    Also you don't need to specify tblA01.* in the first line and some DBs will refuse the statement if you do. The reason is that a DELETE works across entire rows so you can't specify a field list. Instead just use DELETE FROM.

  5. #5
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: Delete SQL qry Syntax

    You also need spaces around your = sign (or IN, if you changed that). Some dbs may accept it, some may not.
    Tengo mas preguntas que contestas

Posting Permissions

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



Click Here to Expand Forum to Full Width