The following thread got me a good start on automating my front end database deployments.
https://www.accessforums.net/code-re...end-33331.html
I took the code pretty close to the way it was provided on this thread, making changes where necessary, and assigned it to the on open event of a form that loads when the datbase is opened. Here is what my code looks like:
Code:
If Me.txtVersion.Value <> Me.lblVersion.Caption Then
'copy Access file
CreateObject("Scripting.FileSystemObject").CopyFile _
"\\Seafile\Workgroups\Bartender Labels - All Locations\zz-Test back end Here\LabelsTest Version Control.accdb", "c:\", True
'allow enough time for file to completely copy before opening
Dim Start As Double
Start = Timer
While Timer < Start + 3
DoEvents
Wend
'load new version - SysCmd function gets the Access executable file path
'Shell function requires literal quote marks in the target filename string argument, hence the quadrupled quote marks
Shell SysCmd(acSysCmdAccessDir) & "MSAccess.exe " & """" & CurrentProject.FullName & """", vbNormalFocus
'close current file
DoCmd.Quit
End If
In order for the code to work I've created a label on my form on the front end that stores the version number and also added a text box that pulls the version number from a table on the back end. When these two numbers match, the sub ends. When they don't match, the assumption is that there is an available updated front end on the server that is ready for to be copied to the work station. The code looks for the new server side front end and replaces the old work station front end with it.
So far, when the version numbers match nothing happens (as is expected) but when the version numbers don't match strange things happen.
The server side front end has managed to get copied to the work station pretty much every time this code runs, but probably 2/3 of the time seems to be corrupt. Usually I'll get an error message that says:
Unrecognized database format 'C:\LabelTest Version Control.accdb'
followed immediately by another error:
The expression On Open you entered as the event property setting produced the following error: Module not found.
When I close the database and re-open it, I get the following error:
Microsoft Access has detected that this database is in an inconsistent state, and will attempt to recover the database...."
Revovery hasn't been successful yet, and i haven't been able to recover the front end so I've been going back and manually copying it back over from a backup. Does anyone have an idea what might be causing this?
Thanks
Bruce