How could I leave a combo box locked?

Hi guys, how could I leave a combo box (B) locked if the combo box (A) is blank in a base Libreoffice Form?

  • Operating system: Linux Mint 20.1 Ulyssa base: Ubuntu 20.04 focal
  • Database used: Built-in Firebird
  • Version LO: 7.1.4.2

SAMPLE: AMOSTRA.odb - Google Drive

Hello,

Not clear as to the point. Who cares what B is if A is blank? No need to “lock”.

Maybe you have not provided enough background on what is actually happening.

Also, are you certain you mean combo box? Past samples were with list boxes the more common choice for many reasons.

Hello,

Could always set Enabled property with a macro:

oLB = oForm.getByName("Caixa de listagem 1")
oLB.Enabled = false

Setting to true will again allow access.

Hi Ratslinger, I tried using “Enabled” but it didn’t work. A sample of the problem follows. The Macro I’m trying to change is the “Focus” Macro. What is my mistake?

Don’t see any sample.

I just added the description, it took me a bit of a mishap with the computer…

Lost again. Do Not see any macro named Focus.

This is the code:

Sub Focus

DIM oDoc AS OBJECT
DIM oDrawpage AS OBJECT
DIM oForm1, oCtrl1, oCtrl2 AS OBJECT

oDoc = thisComponent
oDrawpage = oDoc.drawpage
oForm1 = oDrawpage.forms.getByName("Form_Buscar")
oCtrl1 = oForm1.getByName("Sintomatologia")
oCtrl2 = oForm1.getByName("Caixa de combinação 2")

If 	oCtrl1.Text = "" Then
	oCtrl2.oForm1.getByName("Caixa de combinação 2").Value = false

Else
	oCtrl2.oForm1.getByName("Caixa de combinação 2").Value = true
End If

oForm1.reload()

End Sub

Just saw the code. Where is this from:

oCtrl2.oForm1.getByName("Caixa de combinação 2").Value = false

The code I presented was for .Enabled = false

I made the Change, however the message appears: Property or method not found: oForm1

Variety of basic items wrong with your code. The error from oForm1 was because of a wrong form name.

Corrected code (tested):

Sub Focus
DIM oDoc AS OBJECT
DIM oDrawpage AS OBJECT
DIM oForm1,oForm2, oCtrl1, oCtrl2 AS OBJECT
oDoc = thisComponent
oDrawpage = oDoc.drawpage
oForm1 = oDrawpage.forms.getByName("Form_BUSCA 01")
oCtrl1 = oForm1.getByName("Sintomatologia")
oForm2 = oDrawpage.forms.getByName("Form")
oCtrl2 = oForm2.getByName("Caixa de combinação 2")
If  oCtrl1.Text = "" Then
    oCtrl2.Enabled = false
Else
    oCtrl2.Enabled = true
End If
oForm1.reload()
End Sub

It worked perfectly here too, thank you so much Ratslinger. I still have a lot of difficulties with Libreoffice BASIC, but I’ve already learned a lot from this forum.