access 97

  • Thread starter Thread starter lou D
  • Start date Start date
L

lou D

I run access 97 in windows xp pro. I created a form using
the datasheet wizard based on a table. I set the default
view as datasheet and the views allowed as datasheet. When
I open the form by clicking on it in the forms tab it opens
in datasheet view. When I open it using the switchboard it
opens in form view. I can switch to datasheet view but why
won't it open in datasheet view?
 
I run access 97 in windows xp pro. I created a form using
the datasheet wizard based on a table. I set the default
view as datasheet and the views allowed as datasheet. When
I open the form by clicking on it in the forms tab it opens
in datasheet view. When I open it using the switchboard it
opens in form view. I can switch to datasheet view but why
won't it open in datasheet view?

Because you MUST open the form explicitly in datasheet view if you
open it from a VBA event:
DoCmd.OpenForm "FormName", acFormDS

If you are using the Access Built-in Switchboard, you'll have to
modify the code somewhat. If you need help with that, post back.
 
If you created the switchboard with the wizard the default code opens
the form in normal view. Change the code to this:

DoCmd.OpenForm "MyForm", acFormDS

Change "MyForm" to your form name.
 
Hi Lou,

Are you trying to open up a form in Datasheet View from the
built-in Access Switchboard Manager?

If so, you have three options (at least) available to you.

1. You could make your form into a Continuous Form and
design it so it *looks* just like a datasheet. Then open
it in Edit mode from the Switchboard.

2. You could design your own "Switchboard-type" form and
launch all your procedures from there. Most, if not all, experts
prefer to build their own unbound forms for this purpose and
avoid using the Switchboard Manager.

3. You can change the Switchboard code a little bit to
achieve your desired result. The Switchboard automatically
will open a form in Single view. If you change the code to
datasheet view then ALL forms will open in Datasheet view
launched from the Switchboard which is probably not a good thing.
If you would like to have the best of both worlds, follow these
instructions on a BACK-UP COPY.

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 rst![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 rst![Argument]

' Open a form in Datasheet Mode.
Case conCmdOpenFormDatasheet
DoCmd.OpenForm rst![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.
 
Although you got some good answers, no one suggested the option I'd use.

In the switchboard manager, select the "Run Code" option.

In the "Function Name" box enter: OpenMyForm

In a standalone module enter:

'<Code>
Public Function OpenMyForm()

DoCmd.OpenForm "frmMyFormName", acFormDS

End Function
'</Code>

This way you don't have to modify the switchboard form's code.

Sco

M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Denver Area Access Users Group Vice President www.DAAUG.org
MS Colorado Events Administrator www.MSColoradoEvents.com
Useful Metric Conversion #18 of 19: 8 nickels = 2 paradigms (My personal
favorite)
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
 
Back
Top