Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete all Records in Access Table (DAO)

Status
Not open for further replies.

Jimgarry

MIS
May 16, 2000
112
Thanks in advance,

I am opeing a access 97 database with DAO I want to select a tabel and delete all the records in the table

here is my code so far :

' remove data from the current salesin table

strSql = "DELETE Salesin.Salesman, Salesin.contact, Salesin.Company, Salesin.phone, Salesin.Ext, Salesin.stage, Salesin.closedt, Salesin.product, Salesin.units, Salesin.price, Salesin.amount, Salesin.prob FROM Salesin;"

Set db = OpenDatabase(strDBLocation)
Set rs = db.OpenRecordset("Salesin", dbOpenDynaset)
Set rs = db.OpenRecordset(strSql, dbOpenDynaset)

db.Close



I run this and get
"Runtime Error 3219"
"Invalid operaton"

Thanks again
Jim
 

try...
[tt]
Set db = OpenDatabase(strDBLocation)
db.Execute "Delete * From Salesin"
db.Close
[/tt]

Good Luck

 
I still get the same error.

I changed my SQL statment to what you have. shorter is better.

Am i missing something on the Database or Recordset?
 
Hey that worked.

the db.Execute "Delete * From Salesin"

Thanks for all your assistance.
shorter sql and db.execute


Thanks again
Jim
 

Does this table have a relationship to another table where this table has the parent key? If so you will have to delete the child records before you can delete these records.

Good Luck

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top