W
Wayne-I-M
Hi All
I have a code that deletes an external database (kill code), imports a new
copy of this (call it DB1), then deletes a few tables from another DB (call
it DB2) and imports new - up to date - copies of these table from DB1 into
DB2.
Sounds daft I know - but it's to ensure that field staff have an up to date
copy of the server backend on any stand alone laptops.
Here is the problem (never underestimate the need for field staff to mess
things up). Everything works fine "unless" either of the DB is missing or
any of the table that are being deleted or imported is not there. How is
this possible hmmmm your guesse is as good as mine.
Is there a way to check that a DB exists or table exists in an external or
home system?
Something like
Iff DB1 exists then
Delete it
Import a new copy
Else
Import a new copy
End if
At the moment the code only works if the DB1 is there - or it can not delete
it so the code stops. The same goes for the tables - if they are not there
they can't be re-written etc etc.
Any tips would be really great
________________________________________
It's not really important but here is the code (the first line is a form -
frmMerchanttimerWait - to tell the field staff not to touch anything - they
ignor it)
Private Sub cboImport_Click()
DoCmd.OpenForm "frmMerchanttimerWait", acNormal, "", "", , acNormal
Dim strOldPathName As String
Dim strNewPathName As String
Kill "C:\Documents and Settings\UKOPS\My Documents\UKOP_Stuff\NewVenture.mdb"
strOldPathName = "S:\NewVenture.mdb"
strNewPathName = "C:\Documents and Settings\UKOPS\My
Documents\UKOP_Stuff\NewVenture.mdb"
DBEngine.CompactDatabase strOldPathName, strNewPathName
DoCmd.DeleteObject acTable, "tblBookings"
DoCmd.DeleteObject acTable, "tblClients"
DoCmd.DeleteObject acTable, "tblEvents"
DoCmd.TransferDatabase acImport, "Microsoft Access", "C:\Documents and
Settings\UKOPS\My Documents\UKOP_Stuff\NewVenture.mdb", acTable,
"tblBookings", "tblBookings", structureonly:=False
DoCmd.TransferDatabase acImport, "Microsoft Access", "C:\Documents and
Settings\UKOPS\My Documents\UKOP_Stuff\NewVenture.mdb", acTable,
"tblClients", "tblClients", structureonly:=False
DoCmd.TransferDatabase acImport, "Microsoft Access", "C:\Documents and
Settings\UKOPS\My Documents\UKOP_Stuff\NewVenture.mdb", acTable, "tblEvents",
"tblEvents", structureonly:=False
End Sub
I have a code that deletes an external database (kill code), imports a new
copy of this (call it DB1), then deletes a few tables from another DB (call
it DB2) and imports new - up to date - copies of these table from DB1 into
DB2.
Sounds daft I know - but it's to ensure that field staff have an up to date
copy of the server backend on any stand alone laptops.
Here is the problem (never underestimate the need for field staff to mess
things up). Everything works fine "unless" either of the DB is missing or
any of the table that are being deleted or imported is not there. How is
this possible hmmmm your guesse is as good as mine.
Is there a way to check that a DB exists or table exists in an external or
home system?
Something like
Iff DB1 exists then
Delete it
Import a new copy
Else
Import a new copy
End if
At the moment the code only works if the DB1 is there - or it can not delete
it so the code stops. The same goes for the tables - if they are not there
they can't be re-written etc etc.
Any tips would be really great
________________________________________
It's not really important but here is the code (the first line is a form -
frmMerchanttimerWait - to tell the field staff not to touch anything - they
ignor it)
Private Sub cboImport_Click()
DoCmd.OpenForm "frmMerchanttimerWait", acNormal, "", "", , acNormal
Dim strOldPathName As String
Dim strNewPathName As String
Kill "C:\Documents and Settings\UKOPS\My Documents\UKOP_Stuff\NewVenture.mdb"
strOldPathName = "S:\NewVenture.mdb"
strNewPathName = "C:\Documents and Settings\UKOPS\My
Documents\UKOP_Stuff\NewVenture.mdb"
DBEngine.CompactDatabase strOldPathName, strNewPathName
DoCmd.DeleteObject acTable, "tblBookings"
DoCmd.DeleteObject acTable, "tblClients"
DoCmd.DeleteObject acTable, "tblEvents"
DoCmd.TransferDatabase acImport, "Microsoft Access", "C:\Documents and
Settings\UKOPS\My Documents\UKOP_Stuff\NewVenture.mdb", acTable,
"tblBookings", "tblBookings", structureonly:=False
DoCmd.TransferDatabase acImport, "Microsoft Access", "C:\Documents and
Settings\UKOPS\My Documents\UKOP_Stuff\NewVenture.mdb", acTable,
"tblClients", "tblClients", structureonly:=False
DoCmd.TransferDatabase acImport, "Microsoft Access", "C:\Documents and
Settings\UKOPS\My Documents\UKOP_Stuff\NewVenture.mdb", acTable, "tblEvents",
"tblEvents", structureonly:=False
End Sub