using api

  • Thread starter Thread starter Afrosheen
  • Start date Start date
A

Afrosheen

I would like to use an api program that I found on
http://www.mvps.org/access/api/api0026.htm. The thing is there is no "call
code" to activate the api program. I was wondering how I would go about doing
that. What the api does is make a copy of the database through programming.

Any suggestions and help?

Thanks for reading this and helping
 
Afrosheen said:
I would like to use an api program that I found on
http://www.mvps.org/access/api/api0026.htm. The thing is there is no "call
code" to activate the api program. I was wondering how I would go about
doing
that. What the api does is make a copy of the database through
programming.

Any suggestions and help?

Thanks for reading this and helping


Once you've copied and pasted the code into a standard module (not a form,
report, or other class module) all you need to call it is ...

fMakeBackup

For example, if you wanted to call it from the Click event procedure of a
command button, the event procedure would look something like this ...

Private Sub MyButton_Click

fMakeBackup

End Sub
 
Thanks Brendan. It works great. The people I'm writing the program for don't
know how to back up a system so I wanted a program that would do just that.

Thanks again..
 
Brendan if your still on, is there a routine I can incorporate that will
delete the last copy/backup? If so could you please send it or direct it tome?

Thanks..
 
To delete a file, you use the Kill statement.

Assuming your current database is C:\Folder\Subfolder\File.mdb, your copy is
going to be named C:\Folder\Subfolder\Copy of File.mdb. Now, the code you
cited uses CurrentDb.Name to get the full path to the file, so presumably
you're going to want to generate the name of the copy dynamically as well
(as opposed to hard-coding it). You could use CurrentProject.Path and
CurrentProject.Name properties to build up the name of the copy:

strCopyFile = CurrentProject.Path & "\Copy of " & CurrentProject.Name

or you can use

strCopyFile = Left(CurrentDb.Name, Len(CurrentDb.Name) -
Len(Dir(CurrentDb.Name))) & "Copy of " & Dir(CurrentDb.Name).

(both of those expressions are supposed to one-liners...)

In either case, once you've got the name of the file in the variable
strCopyFile, you delete it using

Kill strCopyFile

Just to be certain that the file actually does exist, you might be better
off to use:

If Len(Dir(strCopyFile)) > 0 Then
Kill strCopyFile
End If
 
Back
Top