
Problems Executing SQL Statements
First of all, the Delete statement does not return any records, second the
Delete statement is incorrect. Try it like this:
Dim db As Database
Dim rs As Recordset
Dim SQLstr As String
Set db = data1.Database
SQLstr = "DELETE FROM mytable"
db.Execute SQLstr
Set rs = db.OpenRecordset("myTable")
Set data1 = rs
You have to execute the Delete statement first and then get your recordset.
Hope this helps,
Mike Reck
Ameritech Data Networking Solutions
Quote:
>Is there a trick to executing SQL statements in VB? I have no trouble
>executing SELECT statements, but when it comes to doing anything else with
>VB & SQL, I bomb.
>Here is the code I am trying to use to delete all the records in a table:
>Dim db As Database
>Dim rs As Recordset
>Dim SQLstr As String
>Set db = data1.Database
>Set rs = db.OpenRecordset("myTable")
>SQLstr = "DELETE mytable.* FROM mytable;"
>Set rs = db.OpenRecordset(SQLstr)
>Set data1 = rs
>This code produces an invalid operation error (3219).
>As always - any help is greatly appreciated!
>--
>Jeff Miller
>El Paso, TX