Command not available in switchboard form

John Zelmer

Registered User.
Local time
Today, 19:49
Joined
May 13, 2015
Messages
39
Hi, in a start-accdb I'm using the following code:

Shell """" & SysCmd(acSysCmdAccessDir) & "MSACCESS.EXE""" & " """ & "H:\Test-FE.accde"" /cmd" & " ""xyz" & """", vbNormalFocus

to open the main database in which the value "xyz" is checked to see if the database is opened in the right way. I want to prevent users from opening the main database directly.

Strange thing is that I have got this working in the main db on a newly created form that opens on start up: the first thing in the form's open event is the check:

If Not (Command() = "xyz") then
msgbox "You can't.....etc."
application.quit
endif

But now I want to do the same in the main switchboard form and the command value is just empty (null), while at the very same time the command value *is* available on the earlier form I tested with . I have no clue what's going on.

Somebody any idea?
Thanks in advance

John
 
Why not open Access in the normal way then run whatever this xyz command is using an Autoexec macro? Depending on what the code in xyz does its actions should persist so no worry about repeating in the switchboard

Switchboards do have limitations so if you don't want to do what I suggested above, you could always create your own start up form
 
Thanks for your reply Ridders,

The start-db takes care of backup and FE-updating actions which can not be done in the frontend itself. The 'xyz' doesn't represent code but it is just a string that is passed to determine if the main db is started from the start db or directly.

I fiddled around a bit with de AutoExec macro but I found that the startup form is fully opened/visible and only then the AutoExec seems to run. I thought AutoExec runs first. Anyway, I tried in that way to use a global var but that doesn't work. The variable is just not filled when the form's open event runs.

So now I've set the Database Startupform option to none and in the AutoExec macro where the "xyz" check is done, I open the switchboardform when the check turns out positive. If negative I pop up a message and close the db.

John
 

Users who are viewing this thread

Back
Top Bottom