Don
Don

Reputation: 11

How to Disable/Enable two pushbuttons at the same time using a checkbox in LO Basic

I have tried arranging this code a dozen different ways. I am at a loss. It only works on the first button.

The macro runs on a "1' or "0" value in the cell linked to a checkbox. I want either both pushbuttons Enabled or both Disabled.

Can anyone tell why this does not work?

Much thanks in advance

Sub ToggleButtonStatus(pEvent)

activeM = pEvent.Source.Model
activeM2 = pEvent.Source.Model
myButtonName = activeM.Tag
myButtonName2 = activeM2.Tag
theForm = activeM.Parent
theForm2 = activeM2.Parent
myButton = theForm.getByName(myButtonName)
myButton2 = theForm2.getByName(myButtonName2)

If activeM.State = 0 OR activeM2.State = 0 Then
     myButton.Enabled  = False
     myButton.Label   = "Not Enabled"
     myButton2.Enabled  = False
     myButton2.Label   = "Not Enabled"
   Else
      myButton.Enabled = True
      myButton.Label   = "Enabled"  
      myButton.Enabled = True
      myButton2.Label   = "Enabled"
End If   

End Sub

Upvotes: 0

Views: 25

Answers (0)

Related Questions