Conditional activation of a form field

Creating and using forms
Post Reply
calstreet
Posts: 1
Joined: Tue Jan 08, 2019 8:56 am

Conditional activation of a form field

Post by calstreet »

I am trying to create a form for customer profile for which I need to capture if the person married or not based on which a form field with the spouse name should be activated in the form. anyone has any idea on how to achieve this.
Libraoffice 6.1.4.2 on Windows 10
UnklDonald418
Volunteer
Posts: 1547
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Conditional activation of a form field

Post by UnklDonald418 »

To do that requires coded macros. The code to hide or un-hide a form control isn't terribly complex, but it must be modified for that particular form. If you are familiar with writing OO macro code then here is the basic code to Hide and Unhide a form control. Of course it will need to be modified to work with your particular form, and you will need to find appropriate events to trigger the macros.

Code: Select all

REM  *****  BASIC  *****
Sub HideControl ( oEvent as object )

  Dim oControl

  oControl = oEvent.Source.Model.Parent.getByName("Control Name Goes Here")
  oControl.setPropertyValue("EnableVisible", False)

End Sub

Sub UnhideControl ( oEvent as object )

  Dim oControl
  
 oControl = oEvent.Source.Model.Parent.getByName("Control Name Goes Here")
 oControl.setPropertyValue("EnableVisible", True)

End Sub
If you are not familiar with coding macros in OO the learning curve is quite steep.
Andrew Pitonyak has a book that covers OO macros, and another document devoted to Base macros.
http://www.pitonyak.org/oo.php
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Post Reply