Problem with update code

R

richard

Hi

I have been looking for a way to update front ends automatically and came
upon the code below. I have changed it for my file names, however when the
front end needs to update I get an error message saying it cant find the
control Me.TimerInterval
I have tried replacing Me with Forms!Form1(the name of my form) but still it
falls over. This is the first time I have used TimerInterval so I am not
really sure what is going on. Could some one please let me know why this is
falling over other than the form form1 is closed when the timer interval is
specified.




Private Sub Form_Load()

Dim rst As DAO.Recordset
Dim BEPath As String
Dim ServerFile As String
Dim ServerVersion As Integer
Dim LocalFile As String
Dim LocalVersion As Integer



'find location of files (see note about assumptions below)

BEPath = Mid(CurrentDb.TableDefs("Analysts").Connect, 11)
ServerFile = "\\NWAPS-sbs\e\Assistdatabasefe\Database.mdb" '12 is specific
to this app’s backend MyApp_be.mdb
LocalFile = CurrentProject.Path & "\Database.mdb"



'identify the version numbers of the mde files

Set rst = CurrentDb.OpenRecordset("SELECT Version FROM VersionRef IN '" &
ServerFile & "'", dbOpenSnapshot)
ServerVersion = rst!Version
rst.Close
Set rst = CurrentDb.OpenRecordset("SELECT Version FROM VersionRef IN '" &
LocalFile & "'", dbOpenSnapshot)
LocalVersion = rst!Version
rst.Close



'replace local mde if later version is found on server

If ServerVersion > LocalVersion Then
DoCmd.OpenForm "form1"
Kill LocalFile
FileCopy ServerFile, LocalFile
DoCmd.Close acForm, "form1"
End If

Me.TimerInterval = 2000
Set rst = Nothing


End Sub

Second piece of code

Private Sub Form_Timer()

Dim LocalFile As String
Dim CmdToOpen As String



'close Pilot and launch main application

Me.TimerInterval = 0
LocalFile = CurrentProject.Path & "\Database.mdb"
CmdToOpen = """" & SysCmd(acSysCmdAccessDir) & "Msaccess.exe""" & " """ &
LocalFile & """"
Shell CmdToOpen, vbNormalFocus
DoCmd.Quit

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top