If you made a shortcut to be used and the shortcut executed a batch file to open Access then you could just add an xcopy command at the end of the batch file.
I have to take my wife out to supper so I only have time to give you some hints.
First, everyone here is a volunteer who is trying to assist but receives no reward beyond a "thank you".
Second, while people here are trying to help, most are teaching as well and expect you to learn how the suggestions work and apply them to your situation.
Third, I don't know your skill level and neither want to snow you nor sound condescending. There are a number of steps, but most are basic to Windows. Depending on your skill level, you might want to have someone who is Windows-knowledgeable to assist. That person CAN help even if he/she is not Access-knowledgeable. If you don't know how to create a shortcut, look up "shortcut" in the Windows help.
Access has command line options that you don't normally think about, but must use for my suggestion to work. You should be able to bring them up by searching for "command line" in Access help. Also in the Microsoft Knowledgebase:
The shortcut is just like all the other icons on your desktop that you use to start programs. There is data within the icon/shortcut that you can customize. I don't have time to look everything up now, and my file locations would probably be different from yours. You will have to know where the Microsoft Access program resides on your computer to do this.
Start with creating a dummy shortcut to any executable (.exe) file you can find AFTER copying it to your own folder so you cannot damage the original. Right-click the shortcut and select properties. This is so you see what's underneath. The gist of this is to duplicate the process to create a shortcut that opens your database and copy the instruction under the shortcut that opens your database to a text file.
Then open the file and edit it by adding in a copy instruction after the Access command. Xcopy is newer/better/etc than Copy. Close that file. Let's say you named that file DBwithCopy.txt, for example. Change the name of that to DBwithCopy.bat - making it an executable file. Then create a shortcut to that file.
If all goes well, when you double-click the shortcut it will execute the .bat file which opens your database. When you close the database, Windows will return to the next instruction in the .bat file which will perform the copy.
You're welcome! - I'm at home on eastern time, now.
How about this:
I see the path to your database, where do you want the backup copy to end up? It has to be a different folder, otherwise it would just try to overwrite the original.
Also, use Windows Explorer to find out exactly where you have Access. On my PC the full path is:
C:\Program Files\Microsoft Office\Office\MSAcess.exe
Yours may be the same...
With that information I'll get you there tomorrow.
Bob
I can get the bat file to copy my database but not run it.
so far I have got
--------------------
"C:\WINDOWS\Desktop\Finance\test\FinanceFE0304.mdb" the above line doesn't run my database. what should it be to run the database. The bit below works well.but asks if what is being specified is a file or a directory, how do I let it know in the code that it is a file, so that it will not ask the user.
You're welcome! - I'm at home on eastern time, now.
How about this:
I see the path to your database, where do you want the backup copy to end up? It has to be a different folder, otherwise it would just try to overwrite the original.
Also, use Windows Explorer to find out exactly where you have Access. On my PC the full path is:
C:\Program Files\Microsoft Office\Office\MSAcess.exe
Yours may be the same...
With that information I'll get you there tomorrow.
Bob
HTH,
Bob
-----------------------------------------------------------
Bob, my Access is in the same directory as yours. I would like the copy to be made to "C:\Documents and Settings\Sean Owens\My Documents\Backup"
Got my DB to run I needed to precede the database path with
Start
i'm still getting the problem with xcopy asking if the xxxx.mdb specifies a file name or a directory on the target.
I have also noticed that it tries to copy the file as soon as the db is opened from the first line in the .bat file. rather than waiting till the db is closed and then copying the updated xxxx.mdb file.
questions
1) How do I get xcopy to know that it is a file and run without the users input.
2) How do I get the .bat file to not continue copying the db files after its opened the db till the db is closed again, so that it only copies the updated db files.
Your .bat file should contain the following instructions without the blank line that I inserted for readability:
============================================================
"C:\Program Files\Microsoft Office\Office\Msaccess.exe" C:\Documents and Settings\Sean Owens\My Documents\Copy of Recipe collection database.mdb
XCOPY "C:\Documents and Settings\Sean Owens\My Documents\Copy of Recipe collection database.mdb" "C:\Documents and Settings\Sean Owens\My Documents\Backup\" /c /f /r /y
============================================================
Note the first instruction calls Access. It appears that you and Idd are letting Windows decide to load Access. That may be fine - I'm an old mainframer used to spelling things out.
The second instruction (xcopy) requirs the /y parameter to avoid a message asking permission to overwrite the backup copy. You may or may not need the other parameters as I copied this from a .bat file that runs for me every day.
Run your .bat file by double-clicking it and verify it starts your database. Close your database normally. I.E., using the File drop-down and exit or buttons on your forms. What I mean is if you use Task Manager to kill the job, the copy won't run for sure. And there are probably other non-standard ways to exit the database that would not allow the xcopy to run.
Once the .bat file runs to your satisfaction, you need to make a shortcut to it. You can do that by right-clicking the .bat file and following the instructions. Then copy/move the shortcut to your desktop. You'll need do something for each user of the database. Sorry, I'm being ambiguous, but I don't know how you're using your database or how your network is set up. Generally you don't want to put the .bat file in the same folder as the database because that makes it too easy for a User to pick the real database and then the copy won't be performed.
Hope that helps - I need to earn some money for my employer.
To:
xcopy C:\WINDOWS\Desktop\Finance\test\FinanceFE0304.mdb C:\WINDOWS\Desktopxcopy C:\WINDOWS\Desktop\Finance\test\Finance0304.mdb C:\WINDOWS\Desktop
because Windows thinks the destination should have a FOLDER named Finance0204.mdb
One more problem though, the command prompt box stays open as long as the database is open, is there anyway of having it not open or hiding it at least?
Sean Right click on the .bat shortcut and one of the options in there will be a little check box for close on exit. There is also an option for run minimised.
I ran the .bat through a shortcut AND the actual .bat file.
What i mean is when i run the .bat file, Access opens my database but the cmd.exe window thing is in the background (minimized) Is there anyway where the user canot see this at all?
My problem of the bat file copying the files still exists though.
the problem is that the bat file opens the DB and then continues to carry out instructions in the bat file to copy the db files. I thought it would wait till the opened DB is closed before continuing with the remaining commands.
The result of this is that the db files get copied but they are the files prior to new data being input.
Not to my knowledge, but it's probably possible if you dig deep enough. If you have the Access portion working to your satisfaction, you might want to post this question in a Windows forum.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.