Front-end Auto-Update Utility

Henley12

Troy University Fan
Local time
Today, 14:51
Joined
Oct 10, 2007
Messages
222
I am trying to incorporate this utility into my database, but I seem to have a problem with the runtime version of Access 2007. Any ideas on why that may be? I will try to attach a shot of the error I am getting.
 

Attachments

Have you made sure that the code runs before anything else eg. Is the first thing to be run in your startup form.

Because from the error message it looks like something else is running first preventing the auto close and update.

Good luc John :)
 
This is what I have in my startup form. The red text is my code that was already in the startup form. Perhaps I'm doing that part in the wrong sequence?



Option Compare Database
Option Explicit

Private Sub Form_Load()
Dim strFEMaster As String
Dim strFE As String
Dim strMasterLocation As String
Dim strFilePath As String

' looks up the version of the front-end as listed in the backend
strFEMaster = DLookup("fe_version_number", "tbl-version_fe_master")

' looks up the version of the front-end on the front-end
strFE = DLookup("fe_version_number", "tbl-fe_version")

' looks up the location of the front-end master file
strMasterLocation = DLookup("s_masterlocation", "tbl-version_master_location")

' checks for the existence of an updating batch file and deletes it if it exists
strFilePath = CurrentProject.path & "\UpdateDbFE.cmd"

If Dir(strFilePath) <> "" Then
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
fs.DeleteFile (strFilePath)
Set fs = Nothing
End If


' if the current database opened is the master then it bypasses the check.
If CurrentProject.path = strMasterLocation Then

DoCmd.OpenForm "frmAdministrator", acNormal, , , , acHidden

If fOSUserName = "phenley" Then
DoCmd.OpenForm "frmUsers", acNormal, , , , acHidden
DoCmd.OpenForm "frmMainMenu"
'DoCmd.OpenForm "frmTickler"
'DoCmd.OpenForm "frmPending"
Else
DoCmd.OpenForm "frmSecurity", acNormal
End If

DoCmd.Close acForm, Me.Name


Else

' if the version numbers do not match and it is not the master that is opened,
' the database will do the update process
If strFE <> strFEMaster Then
Dialog.Box "Your program is not the latest version." & vbCrLf & _
"The front-end needs to be updated. The program will " & vbCrLf & _
"now close and then should reopen automatically.", vbCritical, "VERSION NEEDS UPDATING"

' sets the global variable for the path/name of the current database
g_strFilePath = CurrentProject.path & "\" & CurrentProject.Name

' sets the global variable for the path/name of the database to copy
g_strCopyLocation = strMasterLocation

' calls the UpdateFrontEnd module

UpdateFrontEnd

Else
DoCmd.OpenForm "frmAdministrator", acNormal, , , , acHidden

If fOSUserName = "phenley" Then
DoCmd.OpenForm "frmUsers", acNormal, , , , acHidden
DoCmd.OpenForm "frmMainMenu"
'DoCmd.OpenForm "frmTickler"
'DoCmd.OpenForm "frmPending"
Else
DoCmd.OpenForm "frmSecurity", acNormal
End If

DoCmd.Close acForm, Me.Name
End If


End If



End Sub
 
The red parts need to be at the very bottom of the procedure. All of the autoupdating code needs to come before it.
 
I have placed it at the bottom, but I am still getting the error. Any other ideas?
 
Does it work if all you have is the update code in the start up form? Got to be honest never tried it in runtime works well when I have used it in normal access though.

You might want to try posting at Utteraccess as well assuming that is Bob Larsons code you are using as he does not post here anymore.

good luck John
 
If you are opening a bunch of other forms, you should do that in a separate event. Perhaps you should just create a special "startup form" and have the code for doing the update in it and then after that code runs, then add the open form to open this one.

Are you sure that nothing else is running? You don't have an AutoExec macro or another form open do you?
 
Also from what I can see if you don't want the update to run if its your "master/design db" being opened this should be run first then skip the update code altogether should it be the case but as SOS said a seperate event may well work better... Not found a problem with macro's yet (specifcally auto exec) myself yet but would depend what your doing if you have any nice thought SOS.

Good luck John
 
I had this exact problem too with Access Runtime 2007. The form I had coming up I put all the same code (minus his in red) before anything else and still had issues. So I took the previous advice created a new form that housed just this code, went to my autoexec macro and placed opening this form before my others and now it works with no errors.

Just an FYI
 

Users who are viewing this thread

Back
Top Bottom