You are sort of on the right track. But when you're working with objects (in your example "sql" is an object of type "Collection") you must create an instance of the object. In your example, this can be done by:
Dim sql as New Collection
-OR-
Dim sql as Collection
Set sql = New Collection
But when it comes to Access VBA I think you're headed down the wrong path. You don't need to create objects to accomplish this task. And I think you have a long way to go before you understand how objects work. I don't know what book you're looking at. But it doesn't look like it has much to do with Access.
What you want to do accomplish can be done in Access like this...
Code:
DoCmd.RunSQL "DELETE * FROM CASH"
DoCmd.RunSQL "DELETE * FROM POSITION"
DoCmd.RunSQL "DELETE * FROM COMPOSITE"
Note that you must break the SQL statement up to make valid SQL statements.
If you don't want your users to be warned that records will be deleted, you can put
Code:
DoCmd.SetWarnings False
before the first RunSQL, and
Code:
DoCmd.SetWarnings True
after the last RunSQL.
There are other ways to accomplish this as well. For instance, you could create 3 queries that will delete from each table. Then use a syntax similar to:
Code:
DoCmd.OpenQuery "qryDeleteAllCashRecords"
to run each query.
You might want to play around with the Northwind sample database to see some code.
Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org