Opening form in datasheet view from a switchboard

E

Eric Boyle

I am not a programmer, but have built several simple
Access databases for my company. Nobody else here knows
Access so I always use a switchboard and try to idiot
proof the database as much as possible. Most people want
their data in Excel so we are always running queries and
exporting to Excel. The switchboard doesn't offer to let
you make a switchboard button to run a query so I have
created "datasheet" forms based on a parameter query so
that I can run them from the switchboard, but when I run
them from the switchboard they come up in "single form"
mode. I have set the form property to "datasheet" and when
I run it from the switchboard it opens in "single form"
mode but then I can click on design view and back to form
view and it will be in "datasheet" mode. Any help would
be appreciated!
Thanks,
Eric
 
F

Fredg

Eric,
Regardless of how you have set up your form to open,
if you are opening it from an event on another form you
must specify Datasheet view:

DoCmd.OpenForm "FormName", acFormDS

Now you have several difficulties.
I gather you are using the Microsoft Add-In switchboard.
Life would be simpler for you if you didn't, and made use of an
unbound form with command buttons.
Much more versatile, and easier to maintain.
And Access will write most of the code if you use the command button wizard.

That being said, you CAN open a query from the Microsoft switchboard.
a) Make a macro (or do it in code) to open the query.
Set the Switchboard to RunMacro (or RunCode) using the
macro name (or the Sub name).
or..
b) Change the Switchboard Code sheet to add the OpenQuery choice.

c) Which brings us back to your opening the form in datasheet view.
You'll need to go into the Switchboard code window and add some code.

We'll add the OpenQuery and OpenForm acFormDS at the same time.

Open the Switchboard Code window.

Find the
Private Function HandleButtonClick(intBtn As Integer)
code line.
A few lines down you'll find the Constants listed.
Add
Const conCmdOpenQuery = 9
Const conCmdOpenFormDS = 10
at the end of the list (I believe there are originally just 8 constants).

Then go down further into the Select Case statements.
Add

Case conCmdOpenQuery
DoCmd.OpenQuery rst![Argument]
Case conCmdOpenFormDS
DoCmd.OpenForm rst!Argument, acFormDS

just before the Case Else statement.

Close the code window.

Open the Switchboard Items table.
Change the Command value for the form you wish to
open from it's current number (either 2 or 3) to 10.

To open the query, you'll next need to open the switchboard manager and add
something to the switchboard to open. Any open Form will do.
Exit.
Re-open the Switchboard Items table.
Change the just added item to
Command 9
Argument QueryName

That should do it.
You cannot make or edit these changes using the Switchboard manager.
You must work around it, as above.

Best advice I can give you is to make your own switchboard form.
Good Luck..
 

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