D
Diogo
Need some help with the fllowing code:
I use it for a aplication to connect to a server and inspect if the version
on the server is grater than the one in the local host.
I does this by comparing a number in VersionRef table in both the aplication
on the server and the local one. This works fine if the aplication on the
server and on the localhost aren't passowrd protected.
Is there a way for me to suplly the passwords (same on both) via VB to the
aplication on the server and the aplication on the local machine.
Code:
Option Compare Database
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("Tabela FsL antiga").Connect, 11)
ServerFile = Left(BEPath, Len(BEPath) - 34) & "Registo documentos
Workflow_fe.mdb" '34 is specific to this app’s backend MyApp_be.mdb
LocalFile = CurrentProject.Path & "\Registo documentos Workflow_fe.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
MsgBox "Existe uma nova versão desta aplicação. A sua versão vai ser
actualizada! Carrege OK e aguarde sff!", vbInformation, "AutoUpdate"
Kill LocalFile
FileCopy ServerFile, LocalFile
End If
Me.TimerInterval = 2000
Set rst = Nothing
End Sub
Private Sub Form_Timer()
Dim LocalFile As String
Dim CmdToOpen As String
'close Pilot and launch main application
Me.TimerInterval = 0
LocalFile = CurrentProject.Path & "\Registo documentos Workflow_fe.mdb"
CmdToOpen = """" & SysCmd(acSysCmdAccessDir) & "Msaccess.exe""" & " """
& LocalFile & """"
Shell CmdToOpen, vbNormalFocus
DoCmd.Quit
End Sub
I use it for a aplication to connect to a server and inspect if the version
on the server is grater than the one in the local host.
I does this by comparing a number in VersionRef table in both the aplication
on the server and the local one. This works fine if the aplication on the
server and on the localhost aren't passowrd protected.
Is there a way for me to suplly the passwords (same on both) via VB to the
aplication on the server and the aplication on the local machine.
Code:
Option Compare Database
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("Tabela FsL antiga").Connect, 11)
ServerFile = Left(BEPath, Len(BEPath) - 34) & "Registo documentos
Workflow_fe.mdb" '34 is specific to this app’s backend MyApp_be.mdb
LocalFile = CurrentProject.Path & "\Registo documentos Workflow_fe.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
MsgBox "Existe uma nova versão desta aplicação. A sua versão vai ser
actualizada! Carrege OK e aguarde sff!", vbInformation, "AutoUpdate"
Kill LocalFile
FileCopy ServerFile, LocalFile
End If
Me.TimerInterval = 2000
Set rst = Nothing
End Sub
Private Sub Form_Timer()
Dim LocalFile As String
Dim CmdToOpen As String
'close Pilot and launch main application
Me.TimerInterval = 0
LocalFile = CurrentProject.Path & "\Registo documentos Workflow_fe.mdb"
CmdToOpen = """" & SysCmd(acSysCmdAccessDir) & "Msaccess.exe""" & " """
& LocalFile & """"
Shell CmdToOpen, vbNormalFocus
DoCmd.Quit
End Sub