View Full Version : Autoexec problem in access 2007


Danielf
12-23-2006, 10:58 AM
Hi,

I had in access 2003 the following macro in the autoexec module:

Function copy database()

Dim fso As Object
Set fso = CreateObject("Scripting.FilesystemObject")
Application.Echo True, _
"Copy of the database is made."
fso.copyfile Application.CurrentDb.NAME, _
Application.CurrentDb.NAME & "bak", True
Application.Echo True, ""
End Function

The purpose is to make a copy of the current database when opening access. It worked in access 2003 but it doesn't work in access 2007.

Why?

Any suggestion please?

Thanks

Daniel

boblarson
12-23-2006, 12:09 PM
Your function worked in my A2k7 database but I had to make a couple of changes:

1. Add Public before the function and remove the space from between copy and database: Public Function copydatabase()

2. I added to my autoexec with the RunCode and set copydatabase() as the function to run.

It ran just fine in my autoexec and created the copy when opened.

Danielf
12-24-2006, 07:39 AM
Hi Bob,

Thanks, it works

Have a nice day

Daniel