Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Switchboard question 2

Status
Not open for further replies.
Jun 10, 2004
58
US
I've got several forms I'm accessing from a switchboard that I want to open in datasheet view. I set the Default View to “datasheet” and Allow Form View to “No.” The forms open correctly (in datasheet view) when opened manually; however, they open in FORM view (not what I want) when opened from the switchboard. Any ideas? Thanks!
 
If you're using that Access inbuilt switchboard thingie, I don't know, I don't use that. If you're using your own command buttons, take a look at the view arguement:

[tt]docmd.openform "someform", acFormDS[/tt]

Roy-Vidar
 
Yes, I'm using the build-in Access switchboard. I might end up having to use macros or something, but I'd really rather get this figured out. Thanks, anyway!
 
How are ya Faith90189 . . . . .

Make sure the [blue]DefaultView[/blue] & [blue]ViewsAllowed[/blue] properties of the forms of interest are set to [purple]DataSheet[/purple] . . . .

Calvin.gif
See Ya! . . . . . .
 
Faith90189 . . . . . In that case, in the On Open event of the forms add the following code:
Code:
[blue]  DoCmd.RunCommand acCmdDataSheetView[/blue]
Out of curiosity, what version Access? (2K here . . .)

Calvin.gif
See Ya! . . . . . .
 
Hi, I think to do what you want you need to modify the switchboard a little. Go to Design View, then code View.

Find the following (there are a few lines added) and add the last line

Const conCmdDataSheet = 14

to your code. You can change the number 14 to the next in the list , probably 9.

Private Function HandleButtonClick(intBtn As Integer)
Dim StSql As String
' This function is called when a button is clicked.
' intBtn indicates which button was clicked.
' 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
Const conCmdOpenPage = 9
Const conCmdOpenTable = 10
Const conCmdOpenQuery = 11
Const conCmdOpenQueryDesign = 12
Const conCmdSnapshot = 13
Const conCmdDataSheet = 14


Once You've added this, scroll on down till you find the following:

Select Case rs![Command]

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

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

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

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

' Customize the Switchboard. = 5
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. = 6
Case conCmdExitApplication
CloseCurrentDatabase

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

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

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

' Open a Table =10
Case conCmdOpenTable
DoCmd.OpenTable rs![Argument], acViewNormal, acReadOnly
' Open Querry = 11
Case conCmdOpenQuery
DoCmd.OpenQuery rs![Argument]

' Open Querry = 12
Case conCmdOpenQueryDesign
DoCmd.OpenQuery rs![Argument], acViewDesign

' Open Snapshot 13
Case conCmdSnapshot
DoCmd.OutputTo acOutputReport, rs![Argument], acFormatSNP

'Use Datasheet 14
Case conCmdDataSheet
DoCmd.OpenForm rs![Argument], acFormDS


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

End Select


I left the extra rows in to show other command that can be added. The only rows that matter are in green.

Do a debug - compile to check for errors.

Final Step:

You can go directly to the Switchboard table and find the column whose header is 'Command'. Scroll down to the form you wish to open in datasheet view and change the number there which is probably a 3 to the number 14 if you used the above example.

So, to recap by doing this you've created a new argument in the switchboard. You use this argument in the switchboard table to open the form in datasheet mode.

Hope that helps.


 
AceMan,

I tried your code (DoCmd.RunCommand acCmdDataSheetView), but I got "error executing command when attempting to open the form from the switchboard. Do I need to add the form name somewhere in this code? Obviously, I'm not a "coder!
 
1.open the table named Switchboard Items
2.find your entry for the Form that you want to open in Datasheet view
3.Ensure that the Command is 14
4.Ensure that the Argument shows the form name you want to open

PaulF


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top