View Single Post
  #7  
Old February 9th, 2006, 04:54 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Calling forms using Switchboard

This is very helpful. But, for those of us who don't usually write code. To
do this go to "Tools, Macro, Visual Basic Editor". After Visual Basic Editor
opens, find the "Form_Switchboard" then begin scrolling through to find the
codes.

Thanks you!!!

"Cydney" wrote:

I was just having this exact problem and found your post. Excellent and
thoroughly researched process. Thank you!!!
--
THX cs


"NewSysAdmin" wrote:

I know how reliant you can become on message boards when you have a problem
that you're stuck on, so I'm posting the following solution. Sorry, I posted
the previous response without testing it fully. My previous post appears to
work until you try another page of the Switchboard, when you click the 6th
and 7th buttons, it does the same thing (tries to open a form in datasheet
view), which I did not want. Please see below for the solution I found that
REALLY WORKS (found on another discussion board posted by Jeff Conrad.) It
involves changing the Switchboard code.

Open the Switchboard code. Find the area that has this:

' Constants for the commands that can be executed.
Const conCmdGotoSwitchboard = 1
Const conCmdOpenFormAdd = 2
Const conCmdOpenFormBrowse = 3
Const conCmdOpenReport = 4
Const conCmdCustomizeSwitchboard = 5
Const conCmdExitApplication = 6
Const conCmdRunMacro = 7
Const conCmdRunCode = 8


Add one more line to the list like this:

Const conCmdOpenFormDatasheet = 9

Now go a little further down the code until you come to
this area:

' Run code.
Case conCmdRunCode
Application.Run rs![Argument]

' Any other command is unrecognized.
Case Else
MsgBox "Unknown option."

In between these two areas we want to add another one for
datasheet view. Add in this new code in the middle so it
looks like this:

' Run code.
Case conCmdRunCode
Application.Run rs![Argument]

' Open a form in Datasheet Mode.
Case conCmdOpenFormDatasheet
DoCmd.OpenForm rs![Argument], acFormDS

' Any other command is unrecognized.
Case Else
MsgBox "Unknown option."

Compile and save the form.

Now you will NOT be able to use the Switchboard Wizard to
use this option. The Wizard will only use the 8 pre-
defined options. To open a form in Datasheet View you will
need to go directly to the Switchboard Items TABLE and add
it yourself. If you study the records you will figure out
what is going on. Just use the number 9 in the Command
field to open a form in datasheet view and showing all
records.




"NewSysAdmin" wrote:

I tried the previous post, and it gave me an error executing the command. By
searching another message board, I found this solution. I added the below
code to the button which the user would click to open the form in datasheet
mode. I put it into an Event Procedure called by the On Click Event.

Private Sub Option6_Click()

DoCmd.OpenForm "Form Name here", acFormDS

End Sub

This worked for me, and seemed to be a very simple fix.

"Mark Phillipson" wrote:

Hi,

The way I do it is:

Create a Function in a Code Module and run the function from the switchboard
(Run Code command).

The code would be something like:

Public Function OpenMyFormInDSView

DoCmd.OpenForm "frmName", acFormDS

End Function


--
HTH

Mark Phillipson

Free Add-Ins at; http://mphillipson.users.btopenworld.com/
"kash" wrote in message
...
How can I call a form in a Datasheet View using a Switchboard?