Copy Database / Drive to Drive / Rename

W

Wayne-I-M

The answer.

I can’t imagine that I am the only IT type to have ever come across this
situation. We have an access system running office in 5 cities from one
backend server. The in-office terminals all run FE.

But
We also have a large number of laptops used by field staff. Due to some
peculiar habits of the field staff's use of the internet ?????, I (as the IT
dept) do not want them “ever†connecting to the in-office system. But of
course any changes I make to the BE will occasionally need placing on the
laptops as a stand alone DB. Oh yes – when field staff leave the company I
reload XP and any other programmes from the original disks – just to be sure
the laptops are clean of bugs.

So how to do this. Of course there is always windows explorer which really
would work fine – but it is time consuming. You can use import / Get
External Date / CreateObject / CopyFile / etc etc etc. But non of these seem
to work very well (this is almost certainly down to me just being crap).

Anyway, here is a solution that you can use if you have the same situation.
BUT BUT BUT

DO NOT use a Kill code unless you know what you are doing or you will be
(really) sad. Once it’s gone (your database) it’s gone ??
________________________________

Simply create a form and a button on it and use this OnClick.

Private Sub ButtonName_Click()
Dim strOldPathName As String
Dim strNewPathName As String

'Delete the old file'
Kill "C:\Documents and Settings\My Documents\DBName.mdb"

'Copy external database to local drive'
strOldPathName = "E:\DBName.mdb"
strNewPathName = "C:\Documents and Settings\My Documents\DBName.mdb"
DBEngine.CompactDatabase strOldPathName, strNewPathName

End Sub

E:\ is a DataStick but this works from/to any drive. Not too sure about
CD/RW or CD/R though.
I have used compact DB at the end as I feel it needs it (not for any other
reason) so this is up to you. Change the path names to what they are and you
up and running.
________________________________
It may be that you want to check that your DB really has transferred across
before you start using it so in this case you could import and use any name
then after you’re happy with it, simply rename the new DB (run the kill code
just before the rename or it will not work)

'Rename the copied DB to another name'
Dim OriginalName, As String
Dim NewName, As String
OriginalName Name = "C:\Documents and Settings\My Documents\DBName.mdb"
NewName = "C:\Documents and Settings\My Documents\SomeNewNameHere.mdb
"Name OriginalName As NewName

Note I have note included a check to see if the DB exists on the laptops as
it always does but you could include this if you feel it ness.

Have fun
 

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

Top