Close an enternal database

S

Shirley

I have a need to update access version, like this:

1. User in Db1 which is saved in user's hard drive, clicking "update"
2. Db1 opens Db2, which is saved in server.
3. Close Db1
4. Db2 running: copy new version from server to user's computer to replace
the old Db1.
5. Db2 opens Db1 (the updated one) again
6. Close Db2.

The problem often occurs between step 2 and 3. DB2 can not execute the copy
until Db1 is closed. I set up "quit" in Db1 code, but it often went dead.

So, how can I close an external Access database that is not opened by the
current DB?

Great thanks!!

Shirley
 
R

Roger Carlson

On my website () I have a small sample database called:
"KeepingDatabasesInSync2.mdb" which does just this. The problem, of course,
is that many times DB1 isn't closed before DB2 tries to do the copying. When
I ran into this problem. I solved it like this. Instead of trying to close
DB1 from DB2, I simply launch DB2 and then have the subroutine in DB2 trap
for the error number (70) that says it can't be copied because the file is
open. I just tell the subroutine to keep trying until it doesn't error out.
Like this:

Function CopyMasterFile()
On Error GoTo Err_CopyMasterFile

MasterFile = FindSource()
Directory = getpath(CurrentDb.Name)
LocalCopy = getfile(MasterFile)

TryAgain:

FileCopy MasterFile, Directory & LocalCopy

Exit_CopyMasterFile:
Exit Function

Err_CopyMasterFile:
If Err.Number = 70 Then '<-- here's the trap
Resume TryAgain
Else
MsgBox Err.Description
Resume Exit_CopyMasterFile
End If
End Function


--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 

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