Again thanks, here is what i ended up with, taking what i had already rewrote from the original and adding the file comparison ideal.
Code:
Option Compare Database
Option Explicit
Public strSource As String
Public strDestination As String
Public strSourcesize As Variant
Public strDestinationsize As Variant
Public fs As Variant
Public linkver As Integer
Public ver As Integer
Public strname As String
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Sub versioncheck()
On Error GoTo ErrorHandler:
DoCmd.Hourglass True
DoCmd.Echo True, "thinking..."
linkver = DLookup("version", "defaultlinkt")
ver = DLookup("version", "defaultt")
'MsgBox "started"
If linkver <> ver Then
Set fs = CreateObject("Scripting.FileSystemObject")
'get source from linked table
strSource = DLookup("felocation", "defaultlinkt")
'set destination as current location
strDestination = CurrentProject.Path & "\"
'copy source to dest
fs.CopyFile strSource, strDestination, True
'source file size
strSourcesize = GetFileSize(strSource)
'destination file size
strDestinationsize = GetFileSize(strDestination)
strname = CurrentProject.Name
DoCmd.Echo True, "Start loop..."
Do While (strSourcesize) <> (strDestinationsize)
Dim Start As Double
Start = Timer
Sleep 1000
If Timer < Start + 3 Then Exit Do
Loop
Set fs = Nothing
Shell SysCmd(acSysCmdAccessDir) & "MSAccess.exe " & """" & CurrentProject.FullName & """", vbNormalFocus
'close current file
DoCmd.Quit
End If
Exit Sub
ErrorHandler:
Call LogError(Err.Number, Err.Description, "newversion_versionchecker()")
End Sub
Function GetFileSize(ByVal strFileName As String)
Dim fso As Variant
Dim File As Variant
On Error GoTo ErrorHandler:
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(strFileName) Then
Set File = fso.GetFile(strFileName)
GetFileSize = File.Size
Else
GetFileSize = -1
End If
Set fso = Nothing
Set File = Nothing
Exit Function
ErrorHandler:
Call LogError(Err.Number, Err.Description, "newversion_GetFileSize()")
End Function
feel free to pick it apart. so far it appears to be working.