|
-
May 31st, 2007, 06:52 AM
#1
Thread Starter
New Member
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
-
May 31st, 2007, 07:11 AM
#2
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
-
May 31st, 2007, 08:18 AM
#3
Thread Starter
New Member
Re: Delete SQL qry Syntax
Thankyou. That's a fundamental aspect I never knew.
-
Jun 1st, 2007, 11:29 AM
#4
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.
-
Jun 1st, 2007, 12:19 PM
#5
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|