My Assistant
![]() ![]() |
|
|
Jun 13 2007, 08:03 AM
Post
#1
|
|
|
UtterAccess Member Posts: 31 |
Is there a way to force an Access application to run using the runtime engine by using VB code?
I can add the \runtime command line to an icon (which works) but if the user starts the full version of Access first and then selects my application, it will run under the full version of Access. I want to force the user to run in the runtime mode because Access 2007 has a bug in that the navigation pane pops open if you use code to llink tables once the application has opened. (See my post "Cannot hide the Navigation Pane in Access 2007 Version: 2007 (12.0) "). This happens even though the hide navigation setting was applied to the current DB. (This bug was confirmed by the forum monitor.) When the navigation pane pops open, user's can see (and potentially select) database objects which I do not want them to have access to. This happens only when running the full version of Access but not the runtime version, hence I want a way to force the app to run under runtime regardless of how the user started the app. |
|
|
|
Jun 13 2007, 08:07 AM
Post
#2
|
|
|
UtterAccess Guru Posts: 814 From: MN |
Convert the program into an MDE (or whatever Access 2007 offers).
I think that will work...even if the user opens Access and then goes into program. Nick |
|
|
|
Jun 13 2007, 08:27 AM
Post
#3
|
|
|
UtterAccess Member Posts: 31 |
Nope....
Doesn't work. I distribute my app as an MDE (sorry, should have stated that). The bug has been confirmed in my Navigation pane post. I'm just looking for a work around until MS fixes it. |
|
|
|
Jun 13 2007, 11:45 AM
Post
#4
|
|
|
UtterAccess Editor Posts: 15,965 From: Northern Virginia, USA |
The /runtime switch is specific to the launching of MS Access for the intention of emulating the Runtime environment... So ... Since the user can do as you have indicated and lauch MS Access, then use Office Icon/Open (aka: File/Open). I would suggest you create an AppLauncher.accdb which is used for the sole purpose of launching your app properly ...
To do this, create your AppLaucher.accdb with and AutoExec macro, or start-up form that executes a function that looks something like this (I used AutoExec in the AppLaucher): CODE Public Function OpenApplication() 'Launch an application with the specified user and password of a specific MDW. Const strAccessLocation As String = "MSACCESS.EXE" Const strDBLocation As String = "C:\SecureLaunch\MyApplication.mdb" Const strPassword As String = "utter" Dim strShellString As String Dim x As Double 'Open the app with the appropriate command line switches. Plus pass as an extra 'security measure, I pass the current time (as Currency) to the CALLED app. The 'called app will look at the Command that was passed and if the difference in time 'is greater the 0.0001 days (about 8 seconds) the launch process fails. strShellString = Chr(34) & strAccessLocation & Chr(34) & " " & Chr(34) & strDBLocation & Chr(34) & _ " /runtime" & _ " /cmd " & CCur(Now) x = Shell(strShellString, vbMaximizedFocus) Application.Quit End Function Then in your application use a start-up form or AutoExec macro to execute code that looks like this (I used a StartUp form, thus the procedure header of Form_Load) CODE Private Sub Form_Load() 'Check to see if the app was lauched with the AppLauncher .. 'if you check the AppLaucher code, you will see that I set the /cmd 'swith to the value of Now(), converted to currency in order to have '4 digit precision of a time stamp, the precision equates to about 8 or 9 'seconds per 0.0001 units, so ... the CALLED app has about 8 seconds to get to this line of code. 'If the app is launch via the File/Open, then the the "Command" will be a ZLS and 'be converted to a 0 ... so the app won't launch with the Open dialog. If Abs(CCur(Now) - CCur(Val(Command))) <= 0.0001 Then DoCmd.OpenForm "frmSuccess" Else MsgBox "You did not start the app with the AppLauncher, please start the program properly" DoCmd.Quit acQuitSaveNone End If DoCmd.Close acForm, Me.Name End Sub The end result is that a user can not open your application OUTSIDE of your AppLauncher ... Granted you can use the ShiftToBypass key, but you can dis-able that feature.. but thats no garentee either. So you can actually expand upon the start up code and set up some stuff (like a global variable), that is checked with each action the user tries to take ... but that is another discussion (IMG:style_emoticons/default/smile.gif) ... I have attached a sample of the above technique. The files MUST be extracted to C:\SecureLaunch. There are two files, AppLauncher.mdb and MyApplication.mdb (Sorry I do not have A2007 at my disposal at the moment!). The VBA code is protected with a password (which is "utter"). I DID NOT disable the ShiftToBypass feature, so you can use that to examine the code. Also, as noted, I used the AutoExec macro in the AppLauncher and a StartUp form in the app. There is a way to bypass the AutoExec macro, besides the ShiftKey ( Click Here for more information) so I often use a Start-Up form instead. Also, to learn a technique that can be applied IN ADDITION to what I have just suggested, follow the SECOND link from this which will teach about a developed technique I coined vPPC .. use the sample from the linked post, but learn the concept from the link in that post. I hope this helps you out!
Attached File(s)
|
|
|
|
Jun 13 2007, 02:47 PM
Post
#5
|
|
|
UtterAccess Editor Posts: 15,965 From: Northern Virginia, USA |
... Adding some info that just popped into my mind ...
You can also utilize this method ... CODE SysCmd(acSysCmdRuntime) To determine if the app is being ran in a Runtime environment ... CODE If SysCmd(acSysCmdRuntime) = False Then
MsgBox "You can not run this app OUTSIDE of the Runtime environment ... please lauch the program properly" DoCmd.Quit acQuitSaveNone Else ' Procede as per norm End If |
|
|
|
Jun 14 2007, 03:30 AM
Post
#6
|
|
|
VIP Emeritus Posts: 2,421 From: UK |
If Not SysCmd(acSysCmdRuntime) Then
'A full version of access is in use, not a runtime Application.Quit acSave End If Stops the user from using the full version |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 19th May 2013 - 08:10 AM |