I have an automatic updater (sort of).
It's a bit long winded and convoluted but its been working a charm for me for the last 10 months or so.
Firstly you implement a 'launcher' file, which contains the code to update the frontend you actually want people to use, (on the users machine this must in this example be co-located with the 'local' frontend). And move a 'master frontend' to a location (preferably near your tables so everyone using it can access it)
You will need to implement two version tables one in the backend (Tbl_R_version, with two fields, RV_ID,RV_Date), one in the frontend (Tbl_L_Version, again with two fields LV_ID, LV_Date). Set the ID fields to autonumber, and the dates, to date.
Then in the launcher files forms open event I then use a piece of code, to check the two versions i.e:
Code:
dim localfile as string
dim serverfile as string
dim backend as string
dim localversion as string
dim remoteversion as string
dim cmdtoopen as string
backend ="filepath to your backend goes here"
localfile = currentproject.path & "\" & "frontend filename here"
serverfile = "filepath to the master frontend"
set rst = currentdb.openrecordset("select max([LV_ID]) as myrmax FROM [Tbl_L_Version] IN '" & serverfile & "'", dbopensnapshot)
remoteversion = rst!myrmax
rst.close
set rst = currentdb.openrecordset("SELECT max([LV_ID]) as mylmax FROM [Tbl_L_Version IN '" & localfile & "'", dbopensnapshot)
localversion = rst!mylmax
rst.close
if remoteversion >localversion then
if dir(localfile) <> "" then
kill localfile
endif
filecopy serverfile,localfile
endif
cmdtoopen = """"&syscmd(acsyscmdaccessdir) & "msaccess.exe"""& " """ & localfile & """"
shell cmdtoopen, vbnormalfocus
docmd.quit
Then, to prevent people circumventing the launcher and using the frontend directly and skipping out on an update I insert this code on the frontend startup form, on the open event.
Code:
Dim Local_Version as long
Dim Remote_Version as long
Local_version=dmax("[LV_ID]","[Tbl_L_Version]")
Remote_Version=Dmax("[RV_ID]","Tbl_R_Version]")
if remote_Version>Local_version then
msgbox "Your frontend is out of date, please use the launcher to run this program and receive updates. The file will now close"
docmd.quit
I also implement a small section of code to prevent users just running the 'master' frontend this again goes on the start forms open event (on the frontend).
Code:
dim denialpath as string
dim filepath as string
denialpath="filepath to master frontend goes here"
filepath=currentproject.path
if filepath=denialpath then
msgbox "Running the database from this location is disabled as it prevent propagation of user update, please run your local frontend. The database will now close"
docmd.quit
endif
Right I think i have confused everyone long enough! I have a section of code I use on my master file to lockdown and unlock the master database, and automatically create mde's and place then in the relevant area and update the associated tables, but right now my fingers are tired! (that wasnt copypasted it was hand typed from my second screen!). If you have any questions on it, please ask, but in all honesty my brain rarely functions on more than one cylinder lately, so please forgive me if nothing makes sense!
(admittedly I did tidy the code up a little and use good names and and naming conventions as i now do, but i did not use myself initially and believe me I wish I did!)