Use Macro (or VBA/Module) To Determine If Runtime Environment Is B

G

genegal

Afternoon everyone,

I'm attempting to use an AutoExec code that will execute certain functions
when the database opens. However, I know that some people in the Office have
the full version of Access, while others need to use the runtime environment
to run the database. The problem with using the runtime environment is that
the LockNavigationPane event in AutoExec won't execute because the navigation
pane does not exist in the runtime environment, which then forces the
database to close on a macro error.

I originally tried to use On Error Next in the AutoExec macro, but the
runtime environment won't recognise that. So I was wondering if there is some
way that I can tell the AutoExec macro to check whether the full Access
program or runtime environment is being used, hence determine the code to be
used.

So, basically I'm wondering if it's possible for the AutoExec macro to
include a piece of code to determine whether the runtime environment is being
used or not.

Thank you for your time.
 
T

Tom van Stiphout

On Wed, 10 Feb 2010 20:38:01 -0800, genegal

To check if using runtime, use the SysCmd method of the Application
object, with the acSysCmdRuntime parameter.
You can call VBA code from a macro using the RunCode action.

-Tom.
Microsoft Access MVP
 
G

genegal

Thank you for both your posts, I will try implementing it soon, and will keep
you informed on how it goes.
 
G

genegal

It hasn't seemed to work, this is the code I put in:

Function StartUp()

If SysCmd(acSysCmdRuntime) = True Then
DoCmd.OpenForm "Task List", acNormal, , , acFormEdit, acWindowNormal
DoCmd.OpenForm "Getting Started", acNormal, , , acFormEdit, acWindowNormal
Else
RunCommand acCmdWindowHide
DoCmd.OpenForm "Task List", acNormal, , , acFormEdit, acWindowNormal
DoCmd.OpenForm "Getting Started", acNormal, , , acFormEdit, acWindowNormal
DoCmd.LockNavigationPane True

End Function

Any idea what could be wrong? Did I know declare the SysCmd properly in the
"If" statement?
 
G

genegal

I forgot to mention the problem:

When I simulate the runtime environment:

F:\...\Tasks To Complete.accdb /runtime

I get the error:

"The command or action "WindowHide" isn't available."

I know this command is not available in runtime environment, but it seems
that the runtime simulator doesn't interpret the runtime environment
statement (If SysCmd(acSysCmdRuntime) = True...).

Any idea what is going on?
 
G

genegal

PROBLEM SOLVED:

AutoExec macro was not saved properly. Something happened not sure what, it
wouldn't be editted). So I had to delete it and recreate the AutoExec macro.
 

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