Full Version: Setting A Property Value
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
ebwhittaker
I have an ActiveX that displays an image and this works fine. Part of the Options available include setting a property called OnClick and it has a few built in options ... Like DisplayLargeImage
How do I setup a command button to change this to another option?

thanks
ed

GroverParkGeorge
Well, it's probably difficult for others to offer too many suggestions since we don't know WHICH ActiveX control this is (native to Windows or a 3rd party control), but as a general rule, if the control exposes properties, you can manipulate them in VBA. This is an entirely different control, with different properties, but here's an example to show the general idea you might be able to implement if you know the appropriate properties for your control.

This control exposes several properties and an event, called NodeClick, which fires when any node in the tree is clicked.

CODE
Private Sub TreeViewMenu_NodeClick(ByVal Node As Object) ' This is a treeview control with exposes a "NodeClick" event
Dim dbs As Database
Dim intNodeIndex As Integer
Dim strNodeCommand As String
Dim testnode As Variant
Dim appC As New Appconstants

On Error GoTo errHandler
Call FormCaption(frm:=Me, sCap:=Node.Text) ' each node in the control has a .text property. Call the procedure "FormCaption" to swap out the form's caption for each selection in the treeview
intNodeIndex = Node.Index ' each node has a .Index property
testnode = Node.Key 'each node has a .Key property

strNodeCommand = DLookup("Argument", "tblTreemenu", "tblTreemenu.key = '" & testnode & "'") ' retrieve the name of the argument from a lookup table. it'll be either a form name or one of two other actions

Select Case strNodeCommand

Case "Exit" ' if the user clicks the node labelled "exit", we bail out and go home for the day
    Me.sfrmDisplay.SourceObject = "frmBlank"
    Set dbs = CurrentDb
    dbs.Properties!AppTitle = appC.AppName
    Me.Application.RefreshTitleBar
    Application.Quit
Case "Calculator" ' if the user wants to open the pop-up calculator, it's different from loading a subform
    DoCmd.OpenForm "frmCalculator", acNormal
  
Case Else ' otherwise, load the form into the subform control and reexpand all of the nodes in the tree view
    Me.sfrmDisplay.SourceObject = strNodeCommand
    ActiveXCtl4.Nodes(intNodeIndex).Expanded = True
End Select

Cleanup:
    On Error Resume Next
exitProc:
  Exit Sub
errHandler:
    If Err <> AppErr.FormNotFound Then
        Call GlobalErrorMessage(iNum:=Err, iLn:=Erl, sFrm:=Screen.ActiveForm.Caption, sCtl:="Main Menu Control") 'this is MY custom error handler, not provided here
    End If
    Resume Cleanup
    Resume
  End Sub
missinglinq
Also be aware that many ActiveX Controls do not expose all of their properties/events by simply going to the Properties Pane. Often you have to go into the Code Module and use the dropdown boxes to see all of the events that are available for the given ActiveX.

Linq ;0)>
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.