SELECT "Category", "CatID1" FROM "TblCat" ORDER BY "Category"
If I attach the following macro to the 'Changed' event of the Listbox, a message box appears showing the visible column in the listbox ("Category").
It's source is
Code: Select all
SELECT "Category", "CatID1" FROM "TblCat" ORDER BY "Category"
Code: Select all
Sub ReadChoice(oEvent As Object)
Dim MyForm As Object
Dim MyListBox As Object
Dim MyListBoxName As String
MyListBoxName = "cboSearch"
MyForm = ThisComponent.Drawpage.Forms.getbyName("MainForm")
MyListBox = MyForm.GetByName(MyListBoxName)
MsgBox MyListBox.CurrentValue
EndSub
Edit: To save anyone reading all of this, particularly MS Access refugees- you can't read the 2nd (invisible) column in a list box (which has completely different characteristics to the Access List Box) in the same way as you can read a combo box in Access but in cases where you would have used a combo box (eg. to filter a subform or find a record, which was what I was trying to do) you would actually put an extra form into your form (using Form Navigator) then put a List Box into it along with the bound field. This filtering form would usually be based on a Filter Table ie one whose purpose is to hold a single line only which is used for filtering or finding records. When the list box has made its choice, the value you require will be in its bound field. This filter table can be used as a main form with the form you want to filter as its subform with linked Master/Child Fields so no code is required or with macro code to temporarily filter the subform. For this latter purpose you may want to use a combo box (a very different animal from the Access Combo) and code like that here http://user.services.openoffice.org/en/ ... 39&t=29786 which filters a form which contains the actual text by which you want to filter. The list box is what you would use if the form you want to filter contains list boxes displaying data from linked tables rather than the actual text you want to find. |