Forum Discussion
Problem with list box selecting individual records
To offer an in-depth answer, we'd need more detail, but in general it's possible to suggest some things for you to review.
First, the List box is bound to a particular column, which by default Column(0). As an aside, columns in list boxes as well as combo boxes are indexed from left to right, starting with 0. That means the first column on the left is Column(0). That's the one you are using according to your posted code.
That column and selected row in the list box refers to one and only one value. That's the one which you indicate is being used to filter the second form, i.e. "EditData". And that is why it only displays a single record.
In order to select MULTIPLE records, you have to figure out which values are common to all of the desired records, and that would be the one which relates to records in the other table containing those multiple records.
This is just a guess, based on 25+ years of experience and the hints available in your description. I imagine you have two tables, not one. And these tables would be
- "Client" in which the basic Client data is stored. Each client has one unique ID field, probably an AutoNumber.
- "Equipment" in which all of the equipment assigned or issued or sold to clients is recorded. Each Equipment record also has one unique ID field, probably also an AutoNumber. HOWEVER, and this is the important point, this Equipment table (or whatever you called your version of it) also has a field for the ClientID that relates back to the Client table. This allows you to record one or more pieces of equipment (software or hardware) for each client. And THAT is the table you want to refer to when opening this "Edit Data" form and that is the ClientID you want to pass to it in your VBA.
It sounds like one of two possibilities is where the problem lies.
Either the "Edit Data" form is bound to the Client table, so you only get that one client record. You can not show multiple equipment records from the second, Equipment, table that way.
Another possibility is that the list box is bound to the Equipment table since what you want to do is work with multiple equipment records. And that means you should pass the ClientID to it, not the EquipmentID. If this is the scenario that applies to your situation, that means, I think, your list box Column(0) actually is bound to the EquipmentID, not to the ClientID and that is the value being sent to the Edit Data form.
Since I can't see how this is all set up in your form, as I say, this is just a series of educated guesses. Hopefully, though, it can send you in the right direction to look for answers.