[Solved] How to have a connection between List and Combo Box

Creating and using forms
Post Reply
path32
Posts: 136
Joined: Tue Oct 11, 2011 5:44 am
Location: Philippines

[Solved] How to have a connection between List and Combo Box

Post by path32 »

i am creating a inventory system but i am a newbie to this platform
i'm using a Open Office Base

want to know how to connect the combo box to list box
if i choose the item from the combo box and it will displayed to the list box

table= Item ( "ItemID", "ItemName" )
combo box= "Combo Box 1"
List Box= "List Box 1"

I'm not sure if i gonna use macro and what are the possible codes for it

DataSource = ThisDatabaseDocument.DataSource

oConnection = oDataSource.GetConnection("", "")

oStatement = oConnection.createStatement()

Please don't double-post the same question in different areas of the forum. I have removed your other identical thread. See: The Survival guide (TheGurkha, Moderator)
Last edited by path32 on Wed Oct 19, 2011 2:07 am, edited 1 time in total.
Apache Open Office 3.4, 4.0, HSQLDB 1.8(non embedded database) Windows 7, UBUNTU 10.04
User avatar
DACM
Volunteer
Posts: 1138
Joined: Tue Nov 03, 2009 7:24 am

Re: how to have a connection between List Box and Combo Box

Post by DACM »

Without more information it's hard to understand your use of the Combo and/or List Boxes. But we can always bind the List Box to the same Data field as the Combo Box...and update things with a 'refresh' button or macro...
Attachments
Recipes2 - (link combo to list box demo).odb
linked Combo and List Boxes
(83.13 KiB) Downloaded 487 times
AOO 4.1.x; LO 4.2.x; Windows 7/8 64-bit
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
path32
Posts: 136
Joined: Tue Oct 11, 2011 5:44 am
Location: Philippines

Re: How to have a connection between List Box and Combo Box

Post by path32 »

thanks for the reply sir
i am gonna use 4 drop down list box for an item description
ItemID, ItemType, ItemDetails, ItemBrand

1 Wire 2.0Meters THHN
2 Wire 3.0Meters THHN
3 Bulb 30Watts FireFly
4 Cleaner 1Can Generic
how i connect this with a condition?
if wire is selected the only itemtype i choose to the item type is 2.0 meters and 3.0 meters?

and it will post to List Box
still confused for it

BTW thanks for the sample prog
Apache Open Office 3.4, 4.0, HSQLDB 1.8(non embedded database) Windows 7, UBUNTU 10.04
User avatar
DACM
Volunteer
Posts: 1138
Joined: Tue Nov 03, 2009 7:24 am

Re: How to have a connection between List Box and Combo Box

Post by DACM »

Now it sounds like you're trying to filter List Boxes successively.
See this example of cascading List Boxes: [Example #2] Filter/Search with Forms (leveraging SubForms)
AOO 4.1.x; LO 4.2.x; Windows 7/8 64-bit
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
path32
Posts: 136
Joined: Tue Oct 11, 2011 5:44 am
Location: Philippines

Re: How to have a connection between List Box and Combo Box

Post by path32 »

Thanks for the the reply, it will help a lot :bravo:

how i can edit the codes for it?
If i like a customize the outcome of the Combo Box
Like this:
Function GetSelectedItem( oComboBoxModel As Object ) As String
GetSelectedItem = oComboBoxModel.Text
End Function
And this, i saw it from the Open Office main page
Dim nCount As Integer
Dim sItems As Variant

REM get control
oComboBox = oDialog.getControl("ComboBox1")

REM first remove all old items from the list
nCount = oComboBox.getItemCount()
oComboBox.removeItems( 0, nCount )

REM add new items to the list
sItems = Array( "Item1", "Item2", "Item3", "Item4", "Item5" )
oComboBox.addItems( sItems, 0 )

i search it for a long day and there's no manual coding or edit for coding
Apache Open Office 3.4, 4.0, HSQLDB 1.8(non embedded database) Windows 7, UBUNTU 10.04
User avatar
DACM
Volunteer
Posts: 1138
Joined: Tue Nov 03, 2009 7:24 am

Re: How to have a connection between List Box and Combo Box

Post by DACM »

All four (4) Forms provided in the example cited above ('Students2.odb') accomplish the same function. Three of the four don't use macros at all. And I think the Text Boxes with Nav-Arrows work well for short selection lists.

One of those Forms utilizes macros, and only to refresh the Form, in lieu of using Push Buttons to do the same (assigned the 'Refresh form' action). That's all the code there is (as shown below). The contents of the List Boxes is adjusted (filtered) through the built-in function of SubForms. The code snippets you're posting represent a re-invention of-the-wheel in light of this built-in SubForm function.

Tools > Macros > Organize Macros > OpenOffice.org Basic...
Students2 > Standard > embedded > Macro Name...

Code: Select all

Sub Refresh_MainForm (oEvent As Object) 'List Box > Properties > Events > Item Status Changed
	oForm = oEvent.Source.Model.Parent 'MainForm
	oEvent.Source.Model.commit() 'commits the selected List Box value to the Form only
	oForm.updateRow() 'commits the List Box Boundfield; only this case is necessary here
	oForm.getByName("SubForm1").getByName("listboxClass").refresh 'necessary to update the List Box
	oForm.reload 'updates the SubForm link(s) as necessary to complete the Form 'refresh'
End Sub
Sub Refresh_SubForm1 (oEvent As Object) 'List Box > Properties > Events > Item Status Changed
	oForm = oEvent.Source.Model.Parent
	oEvent.Source.Model.commit()
	oForm.updateRow() 'MainForm current record update
	oForm.reload
End Sub
AOO 4.1.x; LO 4.2.x; Windows 7/8 64-bit
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
path32
Posts: 136
Joined: Tue Oct 11, 2011 5:44 am
Location: Philippines

Re: How to have a connection between List Box and Combo Box

Post by path32 »

Im using LIKE_user_input_filter.odb
and editing for the Content of Subform
because im using 6 master and slaves Field and
the only available is 4 :crazy:

Still Annoying in the use of p1-p4 for the slaves field :roll:
and having a error for parameters

Thanks for the macro code of refresh page
:D
Attachments
Finish.odb
This File
(15.14 KiB) Downloaded 357 times
Apache Open Office 3.4, 4.0, HSQLDB 1.8(non embedded database) Windows 7, UBUNTU 10.04
User avatar
DACM
Volunteer
Posts: 1138
Joined: Tue Nov 03, 2009 7:24 am

Re: How to have a connection between List Box and Combo Box

Post by DACM »

Nice job! Seems to work with some slight modifications.

(1) The SubForm parameter query wasn't mapped to the SubForm Table properly;
(2) the parameters were lower-case in the links so they didn't match the SubForm's parameter query;
(3) and the SubForm master/slave links allow more than four list inputs using the down-arrow and shift-enter after each entry.

And it seems that some filter entries could be Combo Boxes so the second Form employs some.
Attachments
LIKE_user_input_filter - Finish2.odb
6 Text Boxes or Combo Boxes as variable filter inputs
(23.61 KiB) Downloaded 528 times
AOO 4.1.x; LO 4.2.x; Windows 7/8 64-bit
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
path32
Posts: 136
Joined: Tue Oct 11, 2011 5:44 am
Location: Philippines

Re: How to have a connection between List Box and Combo Box

Post by path32 »

thanks for the reply..
i already do that, but i cant replace my textbox to listbox lol
:bravo:
now i will connect my Item, ItemType, Item Size, Item Description to another Table FieldName= Item Details
so Item, ItemType, ItemSize, ItemDescription = Item Details
:knock: more difficult and have a print button :ouch:
Apache Open Office 3.4, 4.0, HSQLDB 1.8(non embedded database) Windows 7, UBUNTU 10.04
Post Reply