Visit our new web pagesWe have launched a new extended set of web pages at www.alvechurchdata.co.uk. These old pages will stay on the server because people still have links to them but they will not be updated. The new version of this page is at www.alvechurchdata.co.uk/hints-and-tips/accswitchboard4.html. |
|||||||||||||||||||||||||||||||||||||
Home About us Development Training Support |
Behind the scenesHow is it doneThe Switchboard Manager in Access is a useful tool and you do not need to know anything about it in order to be able to build your own system of switchboards. It does however show up some useful techniques in Access and, if you know how the system works then you can modify it to extend its capabilities. Switchboard tableThe system relies on a table and a form, both named "Switchboard". If you open the Switchboard table you'll see that it has a simple structure:
This table has five columns:
Switchboard formThe key feature on the switchboard form is the column of eight buttons. VBA functions on the form determine the appearance of these buttons at runtime and respond to the users' clicking the buttons.
Make the buttons visibleWhen the form loads, the FillOptions method creates a recordset from the Switchboard table and loops through it to decide which buttons should be displayed:
For
intOption = 2
To
conNumButtons
Me("Option" & intOption).Visible = False Me("OptionLabel" & intOption).Visible = False Next intOption The loop starts at 2 because the first button must always be visible. A second loop then sets the caption associated with each button by reading the ItemText field from the recordset:
Me("OptionLabel" & rst![ItemNumber]).Caption _
= rst![ItemText] Deciding what action to takeEach button calls HandleButtonClick in its Click event and each passes its identifying number into that function. Inside the function there's some DAO code which finds the record in the Switchboard table:
rst.FindFirst "[SwitchboardID]=" & _
Me![SwitchboardID] & " AND [ItemNumber]=" & intBtn It retrieves the contents of the Command field from that row and uses that number in a Case structure:
...
' Open a form in Add mode. Case conCmdOpenFormAdd DoCmd.OpenForm rst![Argument], , , , acAdd ' Open a form. Case conCmdOpenFormBrowse DoCmd.OpenForm rst![Argument] ' Open a report. Case conCmdOpenReport DoCmd.OpenReport rst![Argument], acPreview ... In each of these cases, the holds the name of a form or a report in the database and the methods of the DoCmd object open the selected form or run the selected report as appropriate. The constants such as are all defined at the top of the HandleButtonClick function. If you need to extend the range of actions available to the switchboard you could add a new constant:
Const conCmdExportToXL = 9
and extend the cases with a call to DoCmd.TransferSpreadsheet(...). Final warningI can't guarantee that anything I've said on this page will work with your database.The usual warnings apply if you decide to bypass the Switchboard Manager and change the table or form directly:
Part 1
Getting started
|
Hints & tips
The textbox class in Visual FoxPro 9 has a new Autocomplete
property which shows the user the previous values that have
been entered in that textbox.
More...
|
|||||||||||||||||||||||||||||||||||