Good day!
It's my first time using LibreOffice Base and I'm not very familiarized with the way Macros and SQL programming work in this tool.
What I want to do is to have either a push button or a check button that when pushed enables or disables a control or a series of controls. It seems to me that the simplest way would be to record a macro, but whenever I try to record it, it won't enable or disable the intended field. Instead, it merely goes into and out of design view.
However, I would prefer, if possible, to do this without having to resort to a macro. I believe the solution would have to be SQL, but I'm having a hard time understanding what syntax I would need to use to execute this procedure.
I'm not sure what other information you might require, but let me know.
Ok, after much reading, I've been able to determine how to create a BASIC macro to allow for a check box to activate or deactivate a text control:
Sub enableID
Dim oDocument As Object
Dim oForm As Object
Dim oID As Object
Dim oCheck As Object
oDocument = ThisComponent
oForm = oDocument.getDrawPage().getForms().getByName("MainForm")
oID = oForm.getByName("fmtID")
oCheck = oForm.getByName("switchID")
If oCheck.State = 1 Then
oID.Enabled = "True"
Else
oID.Enabled = "False"
EndIf
End Sub
However, I verified that the check box would clear once I switched to a different record. To stop this from happening I changed all my controls to a sub form except for thecheck box. However, I'm now for some reason being unable to select the SubForm in the macro, indicating that such an element doesn't exist. Here's the code for that:
Sub enableID
Dim oDocument As Object
Dim oForm As Object
Dim oFCheck As Object
Dim oID As Object
Dim oCheck As Object
oDocument = ThisComponent
oForm = oDocument.getDrawPage().getForms().getByName("MainForm")
oFCheck = oForm.getByName("subForm")
oID = oFCheck.getByName("fmtID")
oCheck = oForm.getByName("switchID")
If oCheck.State = 1 Then
oID.Enabled = "True"
Else
oID.Enabled = "False"
EndIf
End Sub
I'm really at a stump here. I know I'm able to select the check box, and I've selected the MainForm before, so why can't I select the SubForm?
EDIT: The response for this problem was actually one of the most baffingly simple things I did not do: close the form and reopen it. It's now working. So, I guess I'm good :)