1.

Solve : Another Access Problem ..?

Answer»

Ok, hopefully this one will be MUCH easier to answer!

I have two listboxes in my Access 2000 Database. One of them contains values (The name of food products) from a table, tblStock. The other contains nothing and is defined as a VALUE List.

I'd like it so that when you press a button, the selected value from the ListBox with Products in is copied to the empty ListBox.

Note: The list box with products in is called List14, the empty list box is called List16.

Here's the code i'm using at the moment;

Code: [Select]Private Sub Command18_Click()
List16.AddItem (List14.Value)
End Sub

It just doesn't seem to be WORKING any ideas? Thanks!This may work:

Code: [Select]List16.AddItem(List14.SelectedItem)

Not sure that a command_click event is the most appropriate. Is there not a event raised when the selection is made?





This one won't work either. It comes up with the error message, "method or data member not FOUND" and it highlights the .SelectedItem element. I can't work out what the extension is for the actual values in the first Listbox. I can ADD ListIndex of the selected product into the second ListBox, but not the actual text itself. .Text doesn't even seem to exist on Access 2000. Code: [Select]List16.AddItem(List14.Selected)

Quote

I can't work out what the extension is for the actual values in the first Listbox. I can Add ListIndex of the selected product into the second ListBox, but not the actual text itself

When writing code, after typing an object name followed by a dot, do you not get a list of properties and methods appearing in a popup box? You may have to play around with these. Listboxes have no Text property but do have a Value and a ItemData property.

I feel as though I've tried all of them. ItemsSelected, Select, Value, ListIndex, List, Column. I'll try some others but It feels hopeless Not too thrilled with this SOLUTION but it worked. I didn't find out how to reference field names in Access, so I took the easy way out and used the table column index

Code: [Select]Private Sub List14_DblClick(Cancel As Integer)
List16.AddItem (List14.Column(1))
End Sub

You may have to play around with the index depending on your table layout. Note that the index is zero based. It's not very pretty but it's serviceable.



The _DblClick event seemed more logical to me...but feel free to change it.


Discussion

No Comment Found