If you can follow this MAKE SURE YOU MAKE BACKUPS before you run any of
this.
Though I don't like to to this, here it goes.
Have a database different back end for every year (this year will be
BE_db2004.mdb, next year BE_db2005.mdb) But keep the same front end. Like I
said before, this will only work correctly if the only way you are updating
the Back end is by linked tables. And if youd don't have any of the linked
tables open at the time this is running (the file copy won't work)
when you run the converttonewFY sub this will happen:
sub converttonewFY()
dim strPath as str
dim strNewBEdb as string
dim strBEDb as string
dim db as dao.database
dim tdf as dao.tabledeg
dim cnn as string
strBEPath = "c:\my docs\"
strBEDb = strBEPath & "2004.mdb"
strNewBEdb = strBEPath & "BE_DB" & (cstr(Year(date)) + 1) & ".mdb"
' copy current back end to new database
filecopy strBEDb , strnewdbedb
'Relink all tables with the new path and delete all data on them
set db = currentdb()
for each tdf in db.tabledefs
if len(tdf.connect)<>0 then
cnn = "MS Access;DATABASE=" & strNewBEdb & ";TABLE=" & tdf.name
tdf.connect = cnn
tdf.RefreshLink
docmd.runsql "DELETE " & tdf.Name & ".* FROM " & tdf.NAME & " ;
"
end if
Next tdf
set db = nothing
End Function
TALONGA said:
Rodrigo,
FY = Fiscal Year.
My intent is to make my database capable of being run by anyone who
follows me into this position. Since we are using it in a military setting,
that means that I could depart on a moments notice and the database
(front-end and back-end) need to set up in such a way that they are king of
NUG proof.
My thought was that I could build a mechanism into the switchboard that
would execute the establishement of a clean database on order at the end of
the fiscal year 1 OCT and then the new person would not have to go through
what I went through rebuilding the database for the new year.
I have thought of building the reports to continue across the FISCAL
years, but generally we close out the files and retire them. If I can
generate the reports by FY, etc, then I think my boss will accept this
solution and then the replication of a clean database will no longer be
necessary.
Appreciate any thoughts and would be happy to "share" responsibility for
this with anyone who can help. Look forward to your response.