wiklendt
i recommend chocolate
- Local time
- Today, 18:05
- Joined
- Mar 10, 2008
- Messages
- 1,746
Hi,
i'm trying to combine the versatility of DCrake's shell extension code (which opens any extension with the native app via shell) with the functionality of Ken Higg's front end loader/version control (which checks and manages version difference of master FE and client FE) but my combinations
'freeze' access.
i can get Ken's loader to work on its own, but don't want to have to manually change the absolute path to the ms access installation depending on the local system and local access version
my split DB is currently distributed over a network share drive (Back End) with local Front End's on users systems -currently limited to 4 machines until i get this FE loader working and i manually update their FE's locally (which isn't so bad, 5 min walk, but automatic would be better)
so i thought DCrake's shell extension code would be a great tweak in Ken's FE loader.
HOWEVER. i can't get the two to dance without stepping in each other's feet. When i add DCrake's code to Ken's module handling the version control, it 'freezes' access and seemingly does nothing (no errors).
Same happens when i put DCrake's code in a form and open the form from the module using "DoCmd.OpenForm"
i feel like i'm way out of my league with trying to modify DCrake's code to work in a module. i once thought i made it work - in fact it seemed to me to work but inexplicably just once and never again.
this is the "just once" code that worked... does anyone have any pointers? (also i can't get the "token" to pass, but actually don't really want/need that). i have hi-lighted in red DCrake's code within Ken's module here (i've broken it up into functions/subs, but it's all one continuous module):
(edit: i've attached this module at the bottom of the post as an exported .bas file, zipped - in case it helps)
header info:
Function fncVersionControlStartup()
and if it's required?... Function fncGetVersion
the sub which copies updated FE:
a macro called "autoexec" runs the following: fncVersionControlStartup () to get everything started.
i have looked into many options for FE autoupdating and like Ken's best. the only thing missing is the ability to open the client FE with the local installation of access on users machines.
i'm trying to combine the versatility of DCrake's shell extension code (which opens any extension with the native app via shell) with the functionality of Ken Higg's front end loader/version control (which checks and manages version difference of master FE and client FE) but my combinations
'freeze' access.
i can get Ken's loader to work on its own, but don't want to have to manually change the absolute path to the ms access installation depending on the local system and local access version
my split DB is currently distributed over a network share drive (Back End) with local Front End's on users systems -currently limited to 4 machines until i get this FE loader working and i manually update their FE's locally (which isn't so bad, 5 min walk, but automatic would be better)
so i thought DCrake's shell extension code would be a great tweak in Ken's FE loader.
HOWEVER. i can't get the two to dance without stepping in each other's feet. When i add DCrake's code to Ken's module handling the version control, it 'freezes' access and seemingly does nothing (no errors).
Same happens when i put DCrake's code in a form and open the form from the module using "DoCmd.OpenForm"
i feel like i'm way out of my league with trying to modify DCrake's code to work in a module. i once thought i made it work - in fact it seemed to me to work but inexplicably just once and never again.
this is the "just once" code that worked... does anyone have any pointers? (also i can't get the "token" to pass, but actually don't really want/need that). i have hi-lighted in red DCrake's code within Ken's module here (i've broken it up into functions/subs, but it's all one continuous module):
(edit: i've attached this module at the bottom of the post as an exported .bas file, zipped - in case it helps)
header info:
Code:
Option Compare Database
'====================================================================================================
' Name: basVersionControl
' Use: Insures user has latest version on their local machine
' Created By: Ken Higginbotham
' Date: 11/14/2007
' Modified By: Agnieszka Wiklendt using Shell Extension code from DCrake
' Date: 11/20/2009
' Called By:
' Calls:
' Update: 11/20/2009, Shell Exntension; by AW
' Notes: Code will now open the front end using the native installed application called by the
' file extension, rather than relying on the exact installed location of MS Access.
' This is to allow users to install or update their Access programs without having to change
' the file path in this code. Also allows users of varying Access Versions to use one loader.
' Unfortunately, this not longer supports the FE "token" feature.
' Update: 11/15/2007, Tweak; by KH
' Notes: The only requirement for this to run properly is for the FE to have a database variable
' named whatever is defined in the constant cstrDBVersionPropertyName. There is a
' complimentary form with code named frmVersionControl which can be imported into the FE that
' will manage this requirement.
'====================================================================================================
Option Explicit
'Configure these==========================
'Front end file name
Public Const cstrFEFile = "ORDERS_ReferenceLabs_fe.mdb"
'Location of master FE file on server
'Const cstrMasterFEPath = "\\wm-icpmr\Data2\SHARED\Cidmls\Molecular Biology\Orders\"
'Location of master FE file in development environment
Public Const cstrMasterFEPath = "C:\Users\Agnieszka\Documents\EDU + WORK\3. Westmead\2006-8 Molecular\Databases\Ordering DB (Terry)\"
'Location of FE on local machines (including dev. environ.)
Public Const cstrClientFEPath = "C:\Program Files\RLSODB\"
'=====================================
'Name of databse version variable
Public Const cstrDBVersionPropertyName = "DatabaseVersion"
'Shell Execute stuff
[COLOR=Red]Public Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpszOp As String, _
ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal LpszDir As String, ByVal FsShowCmd As Long) _
As Long
Public Declare Function GetDesktopWindow Lib "User32" () As Long
Const SW_SHOWNORMAL = 1
[/COLOR]
Code:
Function fncVersionControlStartup()
'====================================================================================================
' Name: fncVersionControlStartup
' Use: Checks if FE is loaded on local machine and checks to make sure it is the latest version
' Created By: Ken Higginbotham
' Modified By:
' Date: 11/14/2007
' Called By: autoexec macro
' Calls: fncGetVersion, subCopyMasterOver
' Update:
'====================================================================================================
On Error GoTo Err_fncVersionControlStartup
'This is the the token value passed from the loader to the FE to make sure you can't open the FE without using the loader
Dim strFEToken As String
strFEToken = "MyTokenValue"
'Section 1: FE Version Stuff
'------------------------------------------------------------------------------------------------
Dim objFileSystem As Object 'Initiates FileSystem Object
Set objFileSystem = CreateObject("Scripting.FileSystemObject") 'Initiates FileSystem Object
'Check to see if FE already exists on client
If Not objFileSystem.FileExists(cstrClientFEPath & cstrFEFile) Then
'If it does not exist then it calls the function that copies it over
subCopyMasterOver
Else
'If it does exist then check the version
If fncGetVersion(cstrClientFEPath & cstrFEFile) <> fncGetVersion(cstrMasterFEPath & cstrFEFile) Then
subCopyMasterOver
End If
End If
Set objFileSystem = Nothing 'Kill the FileSystem Object
'Section 2: Open FE and Closed this Utility Loader Appliction
'------------------------------------------------------------------------------------------------
[COLOR=Red] Dim nDT, nApp
Dim strFile As String
strFEToken = "/cmd " & strFEToken
strFile = cstrClientFEPath & cstrFEFile
nDT = GetDesktopWindow()
nApp = ShellExecute(nDT, "Open", strFile, "", "C:\", SW_SHOWNORMAL)
DoEvents
[/COLOR]
DoCmd.Quit
Exit_fncVersionControlStartup:
Exit Function
Err_fncVersionControlStartup:
If Err.Number = 53 Then
MsgBox "MS Access application file not found. Please contact administrator.", vbCritical, "System Error..."
Else
MsgBox "Please contact administrator." & vbCrLf & Err.Description & vbCrLf & "Code: " & Err.Number & vbCrLf & "Source: fncVersionControlStartup", vbCritical, "System Error..."
End If
DoCmd.Quit
End Function
Code:
Function fncGetVersion(fstrFile As String) As String
'====================================================================================================
' Name: fncGetVersion
' Use: Returns the version number of the passed filename
' Created By: Ken Higginbotham
' Modified By:
' Date: 11/14/2007
' Called By: fncVersionControlStartup
' Calls:
' Update:
'====================================================================================================
On Error GoTo Err_fncGetVersion
Dim DB As Database 'Connection var
Set DB = OpenDatabase(fstrFile) 'Set db to passed filename/path
'Return version to function
fncGetVersion = DB.Properties(cstrDBVersionPropertyName)
'Close db
DB.Close
'Kill object
Set DB = Nothing
Exit_fncGetVersion:
Exit Function
Err_fncGetVersion:
If Err.Number = 3044 Then
MsgBox "Master FE file could not be found. Please contatct administrator.", vbCritical, "System Error..."
ElseIf Err.Number = 3270 Then
MsgBox "Database version number could not be found in master or client FE. Please contact administrator.", vbCritical, "System Error..."
Else
MsgBox "Please contact administrator." & vbCrLf & Err.Description & vbCrLf & "Code: " & Err.Number & vbCrLf & "Source: fncGetVersion", vbCritical, "System Error..."
End If
DoCmd.Quit
End Function
Code:
Sub subCopyMasterOver()
'====================================================================================================
' Name: subCopyMasterOver
' Use: Copies FE to client
' Created By: Ken Higginbotham
' Modified By:
' Date: 11/14/2007
' Called By: fncVersionControlStartup
' Calls:
' Update:
'====================================================================================================
On Error GoTo Err_subCopyMasterOver
Dim objFileSystem As Object 'Filesystem object
'Set Filesystem object
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
'Copy FE file over
objFileSystem.CopyFile cstrMasterFEPath & cstrFEFile, cstrClientFEPath & cstrFEFile
'Kill Object
Set objFileSystem = Nothing
Exit_subCopyMasterOver:
Exit Sub
Err_subCopyMasterOver:
If Err.Number = 76 Then
MsgBox "Local directory not found. Please contact administrator.", vbCritical, "System Error..."
Else
MsgBox "Please contact administrator." & vbCrLf & Err.Description & vbCrLf & "Code: " & Err.Number & vbCrLf & "Source: fncVersionControlStartup", vbCritical, "System Error..."
End If
DoCmd.Quit
End Sub
i have looked into many options for FE autoupdating and like Ken's best. the only thing missing is the ability to open the client FE with the local installation of access on users machines.
Attachments
Last edited: