Thanks Fred
This is what the Switchboard code to open forms look like:
' Open a form.
Case conCmdOpenFormBrowse
DoCmd.OpenForm rs![Argument]
are you saying that I won't be able to open the forms the way they are
designed, unless I explicitly open the individual forms with the acFormDS,
acPreview...etc. ??
thanks!
regards,
T
fredg said:
On Mon, 25 Jul 2005 14:30:02 -0700, tracy wang wrote:
Hi all,
I am trying to figure out a way, so when I press the button to open a form
on the switchboard, the form displayed is exactly how I designed it.
Right now, I have forms that are designed to display datasheet view and form
view. How do I write the code for the switchboard to open up in their own
respective views?
Thanks in advance!
Regards,
T
Regardless of the Form's Default View setting, if you want to open a
form in Datasheet view using code, you must explicitly open it like
this:
DoCmd.OpenForm "FormName", acFormDS
otherwise it will open in Single Form View (or Continuous, if that is
the default view).
You did not state that you are using the Access built-in switchboard.
That switchboard is a complex solution to a rather simple problem.
Life would be simpler for you if you didn't use it, 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.
However, if you use the built-in switchboard here is what you will
need to do.
You'll need to go into the Switchboard code window and add some code.
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 conCmdOpenFormDS = 9
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 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 in Datasheet View from it's current number (either 2 or 3) to 9.
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.