I would think it very possible to do waht you want to do.
If the other table contains the records you want to have selected then you could make a recordset from the other table and then loop through each record in the record set then loop through entries in the listbox and if you find a macth then select it.
here is another idea. Make a query where you have both tables. Select the fields from the first table which you want to see in the listbox. JOIN the two tables on th efields which related them. Change the join to an OUTER join so you always see all records from the first table, even if there is not a related record in the other table.
Now use the query as the Row Source to the listbox.
Now use some code like this. This example has four column. The first three columns come from the first table and the last column comes from the other table. Columns in the listbox are numbered 0 to column count -1. So the last column is 3. This column will be empty if there is NOT a related record. And if there is not then we do not want to mark the row as selected.
NOTE: The listbox must be set to Mulit select otherwise you can only select one row.
Private Sub Form_Open(Cancel As Integer) Dim i As Integer
For i = 0 To Me.List0.ListCount - 1
If Len(Me.List0.Column(3, i)) > 0 Then Me.List0.Selected(i) = True
Sorry for the waiting, I started working again, which meens less time having fun. Thanks for your time, maybe I look into it later, but for now I don't have time.
OK and thanks, drop a comment if you still need help. I'm off on holiday next week :o)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.