[Solved] How achieve listbox content based on another field
[Solved] How achieve listbox content based on another field
Ok, i have not posted on here for a while as i have tried to get this working myself without success.
I have supplied a link to my database in the hope someone can download and take a look as I just cant get it to work.
Any similar examples i can find just cant be adapted (by me) for my needs.
So in the Form PartNumber2 I have everything working ok apart from SimilarPart listbox and ReplacesPart listbox.
The idea is that after the customer has been chosen from the list box the red listboxes will be populated with a list of all PartNumbers related to the CustomerID. The two listboxes will have the same list in them to choose from. When the desired SimilarPart and ReplacesPart have been chosen the record can be saved and the details will update to the PartNumber2 table. I have supplied a Dropbox link for those who care (or should i say dare) to take a look.
I would very much appreciate someone taking a look as I have spent a serious amount of hours try to work this out.
many thanks.
If there is a better way to share the database please let me know.
Link corrected.
https://www.dropbox.com/s/3zjli081zslh8 ... 8.odb?dl=0
I have supplied a link to my database in the hope someone can download and take a look as I just cant get it to work.
Any similar examples i can find just cant be adapted (by me) for my needs.
So in the Form PartNumber2 I have everything working ok apart from SimilarPart listbox and ReplacesPart listbox.
The idea is that after the customer has been chosen from the list box the red listboxes will be populated with a list of all PartNumbers related to the CustomerID. The two listboxes will have the same list in them to choose from. When the desired SimilarPart and ReplacesPart have been chosen the record can be saved and the details will update to the PartNumber2 table. I have supplied a Dropbox link for those who care (or should i say dare) to take a look.
I would very much appreciate someone taking a look as I have spent a serious amount of hours try to work this out.
many thanks.
If there is a better way to share the database please let me know.
Link corrected.
https://www.dropbox.com/s/3zjli081zslh8 ... 8.odb?dl=0
Last edited by Maax555 on Wed Jul 25, 2018 2:57 pm, edited 2 times in total.
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
LibreOffice 6.1.4.2 on Windows 7
Re: How to achieve listbox content based on another field
No takers yet:-(
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
LibreOffice 6.1.4.2 on Windows 7
Re: How to achieve listbox content based on another field
If you have a subroutine to populate a listbox dynamically, it should be simple to pass the selection parameter from the first listbox to that subroutine to control its population.
The code snippet in this thread might be helpful
viewtopic.php?f=21&t=3519
The code snippet in this thread might be helpful
viewtopic.php?f=21&t=3519
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
-
- Volunteer
- Posts: 1547
- Joined: Wed Jun 24, 2015 12:56 am
- Location: Colorado, USA
Re: How to achieve listbox content based on another field
I went to the link you provided and downloaded Project Tracking Test V1.17-RFQ.odb
I see no Form PartNumber2So in the Form PartNumber2 I have everything working ok apart from SimilarPart listbox and ReplacesPart listbox.
Likewise, I find no PartNumber2 table.When the desired SimilarPart and ReplacesPart have been chosen the record can be saved and the details will update to the PartNumber2 table.
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
Re: How to achieve listbox content based on another field
Cascading list boxes with macro code and links to solutions without: viewtopic.php?f=83&t=46470
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
Re: How to achieve listbox content based on another field
oh, really sorry. I will check to see if i have incorrectly uploaded a different version. Really sorry but do very much appreciate taking time to look. Let me come back. Also apologies for delay as I have had a few days holiday.
thanks again.
thanks again.
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
LibreOffice 6.1.4.2 on Windows 7
Re: How to achieve listbox content based on another field
Link in original post now corrected.
thanks
thanks
Last edited by Maax555 on Fri Jul 20, 2018 9:48 am, edited 1 time in total.
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
LibreOffice 6.1.4.2 on Windows 7
Re: How to achieve listbox content based on another field
I have looked at this and in all honesty dont fully comprehend it.RoryOF wrote:If you have a subroutine to populate a listbox dynamically, it should be simple to pass the selection parameter from the first listbox to that subroutine to control its population.
The code snippet in this thread might be helpful
viewtopic.php?f=21&t=3519
My thoughts were that this macros would perhaps create a pop up with the wordlist words to choose from using LO Writer.
I created a new database with a wordlist table, created a form with a listbox and also inserted the macro into a push button.
The result was a failed to connect error.
As there is no example database to download with the above macro in I was a little lost.
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
LibreOffice 6.1.4.2 on Windows 7
-
- Volunteer
- Posts: 1547
- Joined: Wed Jun 24, 2015 12:56 am
- Location: Colorado, USA
Re: How to achieve listbox content based on another field
This should get you started.
Use the Mouse button pressed event of the ListBox control(s).
Since the macro uses the event to identify the which control called it, it should work for both Similar Part and Replaces Part.
Use the Mouse button pressed event of the ListBox control(s).
Since the macro uses the event to identify the which control called it, it should work for both Similar Part and Replaces Part.
Code: Select all
Sub setListBoxListSource(oEvent As Object)
Dim oForm As Object
Dim oModel As Object
Dim strSQL As String
Dim SelectedPos As Integer
Dim SelectedItem As String
Dim CID as integer
'If Not Globalscope.BasicLibraries.isLibraryLoaded("MRILib") Then
' Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
'End If
'Dim oMRI as object
'oMRI = CreateUnoService( "mytools.Mri" )
oModel = oEvent.Source.Model
oForm = oModel.Parent
CID = oForm.getByName("fmtCustomerID").CurrentValue
strSQL="SELECT ""PartNumber"", ""PartNumberID"" FROM ""PartNumber2"" WHERE ""CustomerID"" = " & CID
oModel.ListSourceType = com.sun.star.form.ListSourceType.SQL
oModel.ListSource=Array(strSQL)
oModel.refresh()
'oMRI.inspect oModel
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
Re: How to achieve listbox content based on another field
Many thanks, looking at this now.
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
LibreOffice 6.1.4.2 on Windows 7
Re: How to achieve listbox content based on another field
Brilliant. Works perfectly. Cant thank you (and all the other that have supported me) enough as I now feel I am not far off actually being able to use this database or at least moving on to creating some reports. I still have a lot to do but this was a big sticking point for me, so once again a big thank you.
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
LibreOffice 6.1.4.2 on Windows 7