More Multi Select List box problems

indesisiv

Access - What's that?
Local time
Today, 22:30
Joined
Jun 13, 2002
Messages
265
Help.

I am having problems with a milti select list box.

I have a series of hidden check boxes that i need to select as each relevent selection in the listbox is highlighted. (After update of the list box)

Also as i come into the record i need to do the reverse. (Forms current event) ie. It uses the check boxes to highlight the relevent information in the list box.

Thanks for any help
Steve
 
I can now get the check boxes to select and unselect ... just need a way of getting the checkboxes to select the relevent part in the multi select list box.

btw the check boxes are named chk0 , chk1 ... chk29
if that helps.
chk0 refers to row 0 in the list box
 
Do these checkboxes refer to individual fields in a table?
 
So you basically want the check boxes to be selected based on whether or not the corresponding values in the list box are selected - and vice versa.

I have the same question as Mile-O-Phile, which controls are bound to your source table/query?
 
Steve,

That is, if the checkboxes are not bound to a recordsource, when Access moves to a record on a form they will be checked or unchecked depending on their default value. I think people are wondering, if that's the case, how then their value -- on or off -- can be meaningful for every single record since it will be exactly the same for every single record.

But I am guessing your checkboxes are bound and that you are letting users pick items from an unbound listbox and you then want to change the corresponding checkbox values for your own purposes.

As you hinted, this can be done pretty easily since you are using a naming method that lends itself well to linking the two. Roughly, something like the following put on the On Current Event should get you close to updating the listbox from checkbox choices.

Code:
'Assumes you will never have more items in your
'listbox than the total number of checkboxes
   
    Dim i As Integer
    Dim ChkBoxName As Object
   
    For i = 0 To Me.lstBox.ListCount - 1

     Set ChkBoxName = Forms("FrmCheckList")("chk" & i)
        
        If ChkBoxName.Value = -1 Then
        Me.lstbox.Selected(i) = True

        End If
    
    Next i

Use similar code on the After Update of the listbox to match up your checkboxes to the selections, but reverse the players. See the Selected Property in Help for additional info.

Regards,
Tim
 
pono1 said:
Code:
    Dim i As Integer
    Dim ChkBoxName As Object
   
    For i = 0 To Me.lstBox.ListCount - 1

     Set ChkBoxName = Forms("FrmCheckList")("chk" & i)
        
        If ChkBoxName.Value = -1 Then
        Me.lstbox.Selected(i) = True

        End If
    
    Next i

Or:

Code:
Dim i As Integer

For i = 0 To Me.lstBox.ListCount - 1
    If Me.Controls("chk" & i) = -1 Then Me.lstBox.Selected(i) = True
Next i
 
Thanks

Cheers Tim & Mile .. That is exactly what i was looking for.
 

Users who are viewing this thread

Back
Top Bottom