[Solved] Activate and deactivate a List Box
-
- Posts: 89
- Joined: Tue Jul 16, 2013 2:24 pm
[Solved] Activate and deactivate a List Box
Hello,
in my database I have a macro that runs by a check box that activates or deactivates a List Box manually.
I would like the List Box to be activated automatically when the content of the field Table = "D", that is only when I select "TabD" in the Group Box.
When the Table field is different from "D", the List Box must be disabled.
How do I change the macro?
Thanks.
in my database I have a macro that runs by a check box that activates or deactivates a List Box manually.
I would like the List Box to be activated automatically when the content of the field Table = "D", that is only when I select "TabD" in the Group Box.
When the Table field is different from "D", the List Box must be disabled.
How do I change the macro?
Thanks.
- Attachments
-
- Condominium Fees.odb
- (14.72 KiB) Downloaded 152 times
Last edited by pinco pallo on Fri Oct 27, 2017 7:36 am, edited 1 time in total.
LiBO 6.2.8.2 on macOS 10.12.6 (Sierra)
Re: Activate and deactivate a List Box
http://www.openoffice.org/api/docs/comm ... stBox.html
includes service
http://www.openoffice.org/api/docs/comm ... ntrol.html
which exports interface
http://www.openoffice.org/api/docs/comm ... indow.html
where you find interesting methods.
All this is revealed with maximum ease by the MRI extension.
[Tutorial] Introduction into object inspection with MRI
includes service
http://www.openoffice.org/api/docs/comm ... ntrol.html
which exports interface
http://www.openoffice.org/api/docs/comm ... indow.html
where you find interesting methods.
All this is revealed with maximum ease by the MRI extension.
[Tutorial] Introduction into object inspection with MRI
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
-
- Posts: 89
- Joined: Tue Jul 16, 2013 2:24 pm
Re: Activate and deactivate a List Box
Thank you, but i am only looking for help to modify this code to work with a text box instead with a ceck box.
Code: Select all
REM ***** BASIC *****
Sub c_box_on_off(oEv)
Dim otipo as Integer
otipo = oEv.Source.State
If otipo = 1 Then
oModel = oEv.Source.Model
oModel.parent.getbyname("List Box 1").enabled=true
oModel.parent.reload()
End If
If otipo = 0 Then
oModel = oEv.Source.Model
oModel.parent.getbyname("List Box 1").enabled=false
oModel.parent.reload()
End If
End sub
LiBO 6.2.8.2 on macOS 10.12.6 (Sierra)
Re: Activate and deactivate a List Box
Also posted at
https://ask.libreoffice.org/en/question ... -list-box/
https://ask.libreoffice.org/en/question ... -list-box/
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
-
- Posts: 89
- Joined: Tue Jul 16, 2013 2:24 pm
Re: Activate and deactivate a List Box
Yes, but that macro is different from that posted here.
LiBO 6.2.8.2 on macOS 10.12.6 (Sierra)
Re: Activate and deactivate a List Box
Can you write a short macro to examine the field table for "D" and print a message to say if it is D or not D? If so, then you can simply modify either of your macros to enable or disable the list box on the D condition. Such conditional programming is elementary flow control.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: Activate and deactivate a List Box
What an incomprehensible, complicated mess with two tables!
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
-
- Posts: 89
- Joined: Tue Jul 16, 2013 2:24 pm
Re: Activate and deactivate a List Box
I apologize if I did not explain it.
The main table is Condominium_fees. In the Form with the same name, I use a List Box with the names of the secondary table Condominium_records to enter the Name field.
I look for a way to enter the Name only if the Table field contains the value "D" without using the ceck box that works with the macro.
Can you change the macro? do you need a new one?
Thanks for your patience.
The main table is Condominium_fees. In the Form with the same name, I use a List Box with the names of the secondary table Condominium_records to enter the Name field.
I look for a way to enter the Name only if the Table field contains the value "D" without using the ceck box that works with the macro.
Can you change the macro? do you need a new one?
Thanks for your patience.
- Attachments
-
- Condominium Fees_2.odb
- (14.24 KiB) Downloaded 137 times
LiBO 6.2.8.2 on macOS 10.12.6 (Sierra)
Re: Activate and deactivate a List Box
It's perfectly clear that your database is not properly normalized and that you are not able to overcome this design flaw by means of Basic macros.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
-
- Posts: 89
- Joined: Tue Jul 16, 2013 2:24 pm
Re: Activate and deactivate a List Box
I do not know what is not normalized on my database. There are 2 related tables and a form that compiles a field of a table with the contents of the field of another table. To do so, it uses a List Box.
LiBO 6.2.8.2 on macOS 10.12.6 (Sierra)
Re: Activate and deactivate a List Box
What does A, B and C stand for?
What does the Amount column actually amount?
What are TabA, TabB and TabC within the cross table amount?
What does the Amount column actually amount?
What are TabA, TabB and TabC within the cross table amount?
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
-
- Posts: 89
- Joined: Tue Jul 16, 2013 2:24 pm
Re: Activate and deactivate a List Box
It is a simplified database, those fields are used for other processing.
I need to, if the field Table <> "D" , I can not enter the Name field (therefore List Box deactivate). To avoid mistakes.
I need to, if the field Table <> "D" , I can not enter the Name field (therefore List Box deactivate). To avoid mistakes.
LiBO 6.2.8.2 on macOS 10.12.6 (Sierra)
Re: Activate and deactivate a List Box
Find the right event for the text box and do the right thing if oEv.Source.Text = "D" and the right elseif.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
-
- Volunteer
- Posts: 1544
- Joined: Wed Jun 24, 2015 12:56 am
- Location: Colorado, USA
Re: Activate and deactivate a List Box
I've been messing with this and here is what I did to make it work for me.
The original macro has been modified
I attached this macro to the Mouse button released Event on each of the 4 Option buttons.
But I found that when the next record was displayed state of the "List Box 1" might not reflect what was now displayed. There was a problem also if the first record had D in the Table field.
Addressing these issues required a second macro
This macro is attached to the After record change Event and also the When Loading Event of MainForm.
The original macro has been modified
Code: Select all
REM ***** BASIC *****
Sub c_box_on_off(oEv) '
Dim otipo as BOOLEAN
Dim ACName as STRING
ACName = oEv.Source.AccessibleContext.AccessibleName
If ACName = "TabD" Then
otipo = oEv.Source.State
If otipo Then
oEv.Source.Model.parent.getbyname("List Box 1").enabled=True
End IF
Else
oEv.Source.Model.parent.getbyname("List Box 1").enabled=False
End If
End sub
But I found that when the next record was displayed state of the "List Box 1" might not reflect what was now displayed. There was a problem also if the first record had D in the Table field.
Addressing these issues required a second macro
Code: Select all
REM ***** BASIC *****
Sub c_box_on_off2(oEv)
Dim TblName as STRING
TblName = oEv.Source.getByName("txtTable").Text
If TblName = "D" Then
oEv.Source.getbyname("List Box 1").enabled=True
Else
oEv.Source.getbyname("List Box 1").enabled=False
End If
End sub
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
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
-
- Posts: 89
- Joined: Tue Jul 16, 2013 2:24 pm
Re: Activate and deactivate a List Box
Hi @UnklDonald418, it works perfectly, I do not know how to thank you!
- Attachments
-
- Condominium Fees_3.odb
- (14.67 KiB) Downloaded 164 times
LiBO 6.2.8.2 on macOS 10.12.6 (Sierra)