Online Book Reader

Home Category

Access Cookbook - Ken Getz [314]

By Root 1976 0
for handling multiple types:

Private Property Get ISmartTagAction_SmartTagName(ByVal ismarttag As Long) As String

If (ismarttag = 1) Then

ISmartTagAction_SmartTagName = _

"schemas-microsoft-com/smarttag/northwind#openform"

End If

End Property

The ISmartTagAction_SmartTagCaption property allows you to specify the caption that will be used:

Private Property Get ISmartTagAction_SmartTagCaption( _

ByVal ismarttag As Long, ByVal lcid As Long) As String

ISmartTagAction_SmartTagCaption = "Access Smart Tag Demo"

End Property

The ISmartTagAction_VerbCount is where you specify the number of verbs in the smart tag. In this example, there are two actions that the smart tag can take: opening a form or opening a report:

Private Property Get ISmartTagAction_VerbCount(ByVal bstrName As String) As Long

If (bstrName = "schemas-microsoft-com/smarttag/northwind#openform") Then

ISmartTagAction_VerbCount = 2

End If

End Property

Smart tag action clients will first ask action DLLs for a unique ID integer for each of the verbs it wants to support, passing in the name and ordinal number for each one. Generating the unique ID is totally up to the action DLL, which gives the action DLL more flexibility. For example, a smart tag action DLL can specify the same VerbID value for the same action across smart tag types, or it can use the same VerbID for similar variants of an action. In this example, the ISmartTagAction_VerbID property returns iVerb (the same ordinal number passed in) back to the action client as the unique ID:

Private Property Get ISmartTagAction_VerbID( _

ByVal bstrName As String, ByVal iVerb As Long) As Long

ISmartTagAction_VerbID = iVerb

End Property

The ISmartTagAction_VerbNameFromID property is used internally to represent the verb ID:

Private Property Get ISmartTagAction_VerbNameFromID(ByVal idVerb As Long) _

As String

Select Case idVerb

Case 1

ISmartTagAction_VerbNameFromID = "openCustomers"

Case 2

ISmartTagAction_VerbNameFromID = "openReport"

Case Else

ISmartTagAction_VerbNameFromID = ""

End Select

End Property

The code in the ISmartTagAction2_VerbCaptionFromID2 property checks the VerbID and then uses the "///" syntax to get cascading menus in the smart tag. Figure 16-11 shows the results when the smart tag is accessed in the client application:

Private Property Get ISmartTagAction2_VerbCaptionFromID2( _

ByVal VerbID As Long, ByVal ApplicationName As String, _

ByVal LocaleID As Long, ByVal Properties As SmartTagLib.ISmartTagProperties, _

ByVal Text As String, ByVal Xml As String, ByVal Target As Object) As String

If (VerbID = 1) Then

ISmartTagAction2_VerbCaptionFromID2 = _

"Smart Tag Actions///Open Customer Form"

ElseIf (VerbID = 2) Then

ISmartTagAction2_VerbCaptionFromID2 = _

"Smart Tag Actions///Open Customer Report"

End If

End Property

Figure 16-11. Displaying a fly-out smart tag

The ISmartTagAction2_InvokeVerb2 method provides code to perform the actions that the smart tag takes. The first section of the code sets a variable to point to the Target, which is the Access control object passed in. If the smart tag is defined on a Table object instead of a form control, then Access creates a control under the covers that gets passed to the smart tag DLL:

Private Sub ISmartTagAction2_InvokeVerb2( _

ByVal VerbID As Long, ByVal ApplicationName As String, _

ByVal Target As Object, ByVal Properties As SmartTagLib.ISmartTagProperties, _

ByVal Text As String, ByVal Xml As String, ByVal LocaleID As Long)

On Error GoTo HandleErr:

Dim cb As Access.Control

Set cb = Target

The next block of code validates that the control source is CustomerID. If not, a MsgBox statement provides feedback to the user that the smart tag only works when attached to the CustomerID. If the smart tag is attached to CustomerID, the code gets a reference to the Access.Application object from the Target's Application property:

If cb.ControlSource <> "CustomerID" Then

MsgBox "This action only works if you run it on the Customer ID field.", _

vbOKOnly, "Smart Tag

Return Main Page Previous Page Next Page

®Online Book Reader