Skip to main content

macro to permanently delete a database

Hi Brian - how do you permanently delete a database in a macro? iIE  - is there a parameter to client.deletedatabase  or some other trick to permanently remove the database . THANKS

Brian Element Sun, 02/03/2019 - 08:04

Hi Avi,

Actuall that is it:

Client.DeleteDatabase "Sample-DBASE.IMD"

You need to make sure the database is closed before deleting just like in IDEA so usually I have the:

Client.CloseAll

Client.CloseDatabase "Sample-DBASE.IMD"

command before I use the delete database, that way I know the database is closed.  You also have to make sure that if you have used it in an open function like:

Set db = client.OpenDatabase("Sample-DBASE.IMD")

that you have the

Set db = Nothing

before trying to delete it or else it won't work.

Hope that helps out.

Brian

jmax6 Wed, 06/30/2021 - 09:00

Regards Bryan
I am trying to perform this function of deleting a db, created for a single purpose, but I always get the same error.

Brian Element Wed, 06/30/2021 - 13:17

Hi jmax6,

My guess it that you haven't set the db variable to nothing.  This is one instance if you don't set the db variable to nothing then IDEA thinks the database is still in use even if the script is complete and you won't be able to delete or rename the file.

Instead of Set dbName = nothing it should be Set db = nothing

I think that should fix your problem.