opening forms in Form view AND DataSheet view from a Switchboard (1 Viewer)

tobypsl

Registered User.
Local time
Today, 21:26
Joined
Jun 21, 2006
Messages
28
Several of the commands on my switchboard are used to open forms. The forms are defaulted to open in form view however a couple of them I need in Datasheet view.

I have located the select code for the switchboard command buttons (pasted below) and guess the relevant lines are:

' Open a form.
Case conCmdOpenFormBrowse
DoCmd.OpenForm rs![Argument]


Presumably I can get the datasheet view by changing to:

' Open a form.
Case conCmdOpenFormBrowse
DoCmd.OpenForm rs![Argument], acFormDS



but then all of the forms will open in DataSheet view and I need to be able to specify.

Can anyone suggest the most efficient way of dealing with this ???

Thanks in advance for any bright ideas !


Select Case rs![Command]

' Go to another switchboard.
Case conCmdGotoSwitchboard
Me.Filter = "[ItemNumber] = 0 AND [SwitchboardID]=" & rs![Argument]

' Open a form in Add mode.
Case conCmdOpenFormAdd
DoCmd.OpenForm rs![Argument], , , , acAdd

' Open a form.
Case conCmdOpenFormBrowse
DoCmd.OpenForm rs![Argument]

' Open a report.
Case conCmdOpenReport
DoCmd.OpenReport rs![Argument], acPreview

' Customize the Switchboard.
Case conCmdCustomizeSwitchboard
' Handle the case where the Switchboard Manager
' is not installed (e.g. Minimal Install).
On Error Resume Next
Application.Run "ACWZMAIN.sbm_Entry"
If (Err <> 0) Then MsgBox "Command not available."
On Error GoTo 0
' Update the form.
Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
Me.Caption = Nz(Me![ItemText], "")
FillOptions

' Exit the application.
Case conCmdExitApplication
CloseCurrentDatabase

' Run a macro.
Case conCmdRunMacro
DoCmd.RunMacro rs![Argument]

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

' Open a Data Access Page
Case conCmdOpenPage
DoCmd.OpenDataAccessPage rs![Argument]

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

End Select
 

boblarson

Smeghead
Local time
Today, 13:26
Joined
Jan 12, 2001
Messages
32,059
The MOST EFFICIENT way of dealing with this is just build your own form and don't rely on the switchboards. I never use the switchboards because they are just too limiting (and ugly if you ask me).
 

gcybill

New member
Local time
Tomorrow, 03:26
Joined
May 11, 2009
Messages
1
Replace..
DoCmd.OpenForm rs![Argument]
With..
DoCmd.OpenForm rs![Argument]
If Application.Forms(rs![Argument]).DefaultView = 2 Then
DoCmd.OpenForm rs![Argument], acFormDS
ElseIf Application.Forms(rs![Argument]).DefaultView = 3 Then
DoCmd.OpenForm rs![Argument], acFormPivotTable
ElseIf Application.Forms(rs![Argument]).DefaultView = 4 Then
DoCmd.OpenForm rs![Argument], acFormPivotChart
Else
DoCmd.OpenForm rs![Argument]
End If
Then you can use the switchboard based on Form's DefaultView configuration.
 

dcjjlove

New member
Local time
Today, 15:26
Joined
Feb 12, 2013
Messages
3
Can this be done thru the form properties default view? I select Datasheet but it doesn't seem to matter.
 

Users who are viewing this thread

Top Bottom