I need to write a macro that will be run by clicking a button within a dialog. I need the macro to interact with other controls in the dialog. I found the code below to test how this works, and it fails when I run it. I get an error saying “BASIC runtime error. Property or method not found: Parent.”
What am I missing? Isn’t .Parent the correct way to reference it? How else do I access my dialog?
Sub ButtonClick(oEvent As Object)
' Get the source of the event (the button)
Dim oButton As Object
oButton = oEvent.Source
' Get the model of the button
Dim oButtonModel As Object
oButtonModel = oButton.Model
' Get the parent of the button's model, which is the dialog itself
Dim oDialog As Object
oDialog = oButtonModel.Parent
' End the execution of the dialog
oDialog.endExecute()
End Sub