Copying a DB (1 Viewer)

NickNeville

Registered User.
Local time
Today, 22:16
Joined
May 17, 2009
Messages
119
Good morning all, I wonder if anyone could tell me if it is possible thru code
to auto copy a D/B on closure to another area of the PC, say to Docs/Mine.
I guess I would be looking at an "on Exit" event.Or maybe not ?

Your advice most appreciated

Rgds
Nick
 

Trevor G

Registered User.
Local time
Today, 22:16
Joined
Oct 1, 2009
Messages
2,341
Create a command button for exit and then add the following code behind. You could then change form elements so they can't close the database without clicking on close

Dim sDest As String
Dim sSource As String

sSource = "String Path to Folders Name\MYFILE.MDB"
sDest = "C:\BACKUP\MYFILE.MDB"

FileCopy sSource, sDest
 

NickNeville

Registered User.
Local time
Today, 22:16
Joined
May 17, 2009
Messages
119
Many thanks for your quicko reply Trevor
I give this a go,

Rgds
Nick
 

boblarson

Smeghead
Local time
Today, 14:16
Joined
Jan 12, 2001
Messages
32,059
From your description it sounds like you don't have this database split. It really should be. You should have a backend with just the tables and a copy of the frontend on each user's machine. Even if you are the only one using it, it is good to split so then you are less likely to lose your data if corruption occurs. One thing about copying upon exit. It really should be completely closed when you copy it, so that is impossible if you try to do it from within the database. What I do, with my frontend auto updater code, is to dynamically create a batch file and kick it off when the database closes and then it has a delay so it gives it time enough to exit. Then it deletes the old and copies the new. You could use a similar method and instead of deleting anything it just copies the existing one to the save location.
 

NickNeville

Registered User.
Local time
Today, 22:16
Joined
May 17, 2009
Messages
119
Hi Bob many thanks for your info, Just to let you know that this is a simple
d/b working off one machine. It's a club d/b which has 5 tables and about 12 forms etc. I am basically I am beginner with a little knowledge of VB, but simple stuff.
I would not how how to "split" a d/b, in fact I am amazed that it even works as well as it does, It was about 1 year in the making and I change it every day.I would like to know more as my gun club relies on it for membership fees and scores and things, but as I say it works but I'm never totally sure that it will keep working. Its on 2003 Version by the way./ I once tried to convert it to 2009 version....ha joke. I just hope that it and me are alive in ten years to keep it going.I repair and defrag it once a month and generally look after it. It seems to improve with age, unlike me.
Any help / info with this "splitting" interests me especially if it helps to preserve my masterpiece.
Once again Bob many thanks

Bets rgds
Nick
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 14:16
Joined
Nov 8, 2005
Messages
3,294
split your d/b is quite easy - first make a copy on a memory stick - (In case you **** it up - easliy done - backs ups should be done before you do any changes toth e d/b and then every so often while you are doing your upgrades )-

then follow the wizard on how to split a d/b

Basically the tables are on one side and everything else in the other this is called front end (forms etc) and back end tables (or FE and BE )

if the front end goes tits up - your data is still safe - it its not split and it goes wrong - then your screwed ...

just some advise
 

NickNeville

Registered User.
Local time
Today, 22:16
Joined
May 17, 2009
Messages
119
Hi Garypanic
well .I split my d/b after copying. I note that the tables have been sent to
c/:Docs etc.
I also note that when looking at these tables in the d/b they have a little arrow on the side , I assume this relates to the relationship of the f/e and b/e.
Q. I still have the tables in the main d/b, which means that there are now two sets of the same table.
Also the d/b has a password which does not aqply to the tables in c/:docs
So I a bit confused as to what I have done.

Rgds
Nick
 
Last edited by a moderator:

boblarson

Smeghead
Local time
Today, 14:16
Joined
Jan 12, 2001
Messages
32,059
Delete the local tables from the frontend (click on one and hit the delete key - make sure you are in the FRONTEND and not the backend when you delete) and rename the linked ones (I'm assuming that they have the same name but with a 1 appended) to the original table name.
 

NickNeville

Registered User.
Local time
Today, 22:16
Joined
May 17, 2009
Messages
119
Aha that sounds like something a simpleton like me can understand ! now it's all clear......

very many thanks Bob
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 14:16
Joined
Nov 8, 2005
Messages
3,294
Bobs your man ....
i hack things

Bob makes em'

look on the sampels for a backup solution ...
i do remember one
 

Users who are viewing this thread

Top Bottom