Results 1 to 2 of 2
Thread: Form View (2000)
2005-02-21, 01:04 #1
- Join Date
- Mar 2001
- Thanked 0 Times in 0 Posts
Form View (2000)
I created a form and set it to open in datasheet view. When I open the form directly it opens up correctly in this view. I put a command button on a switchboard to open this same form and it opens up in "form" view rather than dataheet view. Is there a way to correct this? Thanks.
2005-02-21, 01:21 #2
- Join Date
- Mar 2002
- Thanked 29 Times in 29 Posts
Re: Form View (2000)
The code behind the Switchboard form uses DoCmd.OpenForm to open a form. This opens a form in form view by default, regardless of the Default View property of the form. You can add the capability to open forms from the Switchboard in datasheet view, but the Switchboard Manager will not handle this, so you will have to perform some manual edits.
- Open the Switchboard form in design view.
- Select View | Code.
- Locate the HandleButtonClick function.
- At the beginning of this function, there is a list of constants. Add the following line below them:
Const conCmdOpenFormDS = 99
- Further down, there is a Select Case ... End Select block.
- Add the following case:
' Open a form in datasheet view
DoCmd.OpenForm rs![Argument], acFormDS
- Quit the Visual Basic Editor.
- Close and save the Switchboard form.
- Open the Switchboard Items table in datasheet view.
- Locate the record corresponding to the form you want to open in datasheet view (the name of the form is in the Argument field)
- Change the Command field for this record from 3 (=conCmdOpenFormBrowse) to 99 (=conCmdOpenFormDS).
- Close the table.
Test the Switchboard to check that the form now opens in datasheet view.
(PS: I never use forms in datasheet view. I use continuous forms instead.)