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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Form in DS View via Switchboard? 3

Status
Not open for further replies.

DBLoser

MIS
Apr 7, 2004
92
US
I have found that this command will open a form in Datasheet view:

DoCmd.OpenForm FormName, acFormDS, , FormCriteria

But how can I accomplish this through the switchboard buttons. I noticed there is a Switchboard Items table with command and arguements fields and I think this is where the answer may lie but I can't find a good reference to what those values do.

Thanks for any tips!

Bruce
 
Hi

I think the nearest you can get to this from the switchborad as standard is to run a query, put a 9 in the column "Command" and a queryname in the column "Argument"

But if you look at the Function HandleButtonClick, I am sure you could amend it to open a from id DS view

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi Bruce,
I'm assuming that the switchboard in question is the one packaged with MS access example db's.
If so here is a list of the command values that you use in the switchboard table. This was taken from the "Private Function HandleButtonClick(intBtn As Integer)" in the forms vb view.

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
I would THINK that you could customise this list to your requirements and add items to it.

Regards,
Noel.
 
Hi,

I don't think there is any reference documentation on how the Switchboard works.

If you want an option to open a form in datasheet view you can make the following additions to the code for the Switchboard (HandleButtonClick Function).
Add this with the rest of the constant declarations at the top of the function:
Code:
[COLOR=blue]    Const conCmdOpenFormDS = 10
[/color]
Add this within the Select Case Statement:
Code:
[COLOR=blue]    Case conCmdOpenFormDS
        DoCmd.OpenForm rs![Argument], acFormDS
[/color]
Put 10 in the Command field for the appropriate option.

If you wanted to restrict a form to specific criteria directly from the switchboard, you could add another field to the SwitchboardItems table called Criteria and change the above line to:
Code:
[COLOR=blue]        DoCmd.OpenForm rs![Argument], acFormDS, , rs![Criteria]
[/color]

You will have to enter criteria directly into the table.

Playing with the switchboard this way you can implement much more functionality. For example I have created databases that have permissions built into the switchboard to disable buttons for certain users; show different pictures for different menus etc.

I have gone on a bit much but what the hey.

HTH, good luck.

Dean :)
 
If you open your switchboard form in design mode, and click on the code button for that form to see the code behind the form, about half way down you will find a function called HandleButtonClick. You will note that there are various command constants assigned numbers. The one you are looking for would be the last one which is the conCmdRunCode which is assigned an 8.

You will also note there is a table called Switchboard Items. This table holds the info for the buttons on the form. Main Switchboard is one of the items you will see in that table. Note that the SwitchboardID is 1. If you add another record with switchboardid as 1 and then under ItemNumber, put a 1 or a number greater than a number you already have there for another item. Give the item a name under ItemText. This will show on the button. Under command put the number 8 mentioned above.

You must create a sub or function in a module that can be called when the button is clicked. You might put something like this:

Sub OpenFormDS()
DoCmd.OpenForm FormName, acFormDS, , FormCriteria
end sub

Now in the Argument field of the Switchboard Items table, put OpenFormDS.

That should do it.

(This of course is for if you already have the switchboard form created. If it is not created, you can just go through the wizard and when you get to the part where you choose the type of command, coose run code.)

Hope this helps.
 
Thanks all for these valuable tips! This should be plenty to accomplish what I want.

Bruce
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top