using api

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
 
B

Brendan Reynolds

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
 
A

Afrosheen

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..
 
A

Afrosheen

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..
 
D

Douglas J. Steele

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Code will not compile 1
Need Help With API 2
VBA Make Access wait API is not working 6
File Dialog Using API 14
ShellExecute api 3
Custom message box on API 1
File path and name 2
API run program 14

Top