Microsoft Access 2010 Bible

(Rick Simeone) #1

Part IV: Professional Database Development


1040


FIGURE 29.25

Check boxes are a good choice when the user needs to be able to select among a number of options.


The ribbon check boxes you see in Figure 29.25 work exactly as you would expect. The check
boxes may be selected individually, or in any combination. Check boxes are not mutually exclu-
sive, and each check box has its own onAction attribute.

The DropDown control
The DropDown control is more complex than the label, button, and check box examples we’ve
covered. It includes a list of items for the user to choose from. Therefore, a DropDown has a num-
ber of attributes that define its appearance, as well as callbacks that populate its list:

<dropDown
id=“ddLogin”
label=“Login” supertip=“Select your employee name...
screentip=“Login Name”
getItemCount=“onGetLoginCount”
getItemLabel=“onGetLogins”
imageMso=“Private”
onAction=“onLogin”>
</dropDown>

The id, label, screentip, and imageMso attributes define the DropDown control’s appear-
ance. The getItemCount and getItemLabel populate the DropDown’s list. onAction speci-
fies the callback that handles the control’s action.

The VBA callbacks for a typical DropDown are shown in the following code. Two primary call-
backs are required for a DropDown. The first sets the count of items to appear in the list, and the
second actually populates the list.

Public Sub onGetLoginCount( _
control As IRibbonControl, ByRef count)
count = Nz(DCount(“*”, “tblSalesPerson”), 0)
End Sub
Public Sub onGetLogins( _
control As IRibbonControl, index As Integer, ByRef label)
Dim strName As String
strName = Nz(DLookup(“SalespersonName”, _
“tblSalesPerson”, “SalesPersonID = “ & index + 1), ““)
label = strName
End Sub
Free download pdf