Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rename database from another database

Status
Not open for further replies.

PJname

MIS
Jun 15, 2004
73
0
0
US
I have a morning job that I have scheduled to kick off at 0300 am each morning where I work.

What I would like to do as one of the first steps in the Autoexec macro is to rename another database to prevent users accessing while this update is running and once the update has completed, rename back to the original database name. One of the steps in my morning job is to transfer approximately 28 tables to update in another database and sometimes when it gets to this step, someone is in the database where I am trying to update the tables and I have to wait and keep trying the transfer macro and hope whoever is in the database has gotten out by now. This can be very frustrating.

Does anyone have the Visual Basic coding to rename in one MS Access database another MS Access database?

I would appreciate it very much if you could send to me.

Thanks in advance.
 
You can use this in MS-Access to rename a file in your code. I tried it from the immediate window and it worked.

Code:
Name  "c:\temp\OriginalName.mdb"  As  "C:\temp\Renamed.mdb"
 
Thanks sxschech

but how would this be put in the Autoexec macro as the first step? Is this a module?
 
I haven't worked with Macros, so I'll look around to see what I can find.
 
This seemed to work.

In your macro add this:
ACTION
---------
RunCode

FUNCTION NAME
-------------
F_Renameit

------------------------------

Add this to an existing module or create a new module

Code:
Sub S_Renameit()
    Name "c:\temp\OriginalName.mdb" As "C:\temp\Renamed.mdb"
End Sub

Function F_Renameit()
    Call S_Renameit
End Function

I used "F_" to indicate the function part and "S_" to indicate the sub part of the module items

You can then change the file names to their actual names in the module code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top