Hi All,
Can't figure out what the hell I'm doing wrong here!!! :banghead:
I have 2 multi-select listboxes set to simple
The first is use to select a vineyard and the second to display the blocks associated with that vineyard - can get this to work fine - no probs.
What I want to do however is if more than one vineyard is selected the second listbox is hidden as selecting more than one vineyard assumes all blocks selected - this is all good too!
Problem occurs when the user un-clicks a vineyard to go back to displaying only one, therefore unhiding blocks listbox and populating with the correct blocks. My code seems to run on the last clicked item not the item left highlighted
Here's my code:
Private Sub LstCo_AfterUpdate()
Dim varItem1 As Variant
Dim LstCo1 As Control
Set LstCo1 = Me.LstCo
If LstCo1.ItemsSelected.Count = 1 Then
For Each varItem1 In LstCo1.ItemsSelected
MsgBox LstCo1.Column(1) 'display vineyard name for debugging
Me.txtCoID = LstCo1.Column(0)
Me.LstBlk.Visible = True
Me.LstBlk.Requery
Next varItem1
Else
Me.txtCoID = Null
If LstCo1.ItemsSelected.Count > 1 Then
Me.LstBlk.Visible = False
Else
Me.LstBlk.Requery
End If
End If
End Sub
All help greatly appreciated, thank you!
Rachael
Can't figure out what the hell I'm doing wrong here!!! :banghead:
I have 2 multi-select listboxes set to simple
The first is use to select a vineyard and the second to display the blocks associated with that vineyard - can get this to work fine - no probs.
What I want to do however is if more than one vineyard is selected the second listbox is hidden as selecting more than one vineyard assumes all blocks selected - this is all good too!
Problem occurs when the user un-clicks a vineyard to go back to displaying only one, therefore unhiding blocks listbox and populating with the correct blocks. My code seems to run on the last clicked item not the item left highlighted
Here's my code:
Private Sub LstCo_AfterUpdate()
Dim varItem1 As Variant
Dim LstCo1 As Control
Set LstCo1 = Me.LstCo
If LstCo1.ItemsSelected.Count = 1 Then
For Each varItem1 In LstCo1.ItemsSelected
MsgBox LstCo1.Column(1) 'display vineyard name for debugging
Me.txtCoID = LstCo1.Column(0)
Me.LstBlk.Visible = True
Me.LstBlk.Requery
Next varItem1
Else
Me.txtCoID = Null
If LstCo1.ItemsSelected.Count > 1 Then
Me.LstBlk.Visible = False
Else
Me.LstBlk.Requery
End If
End If
End Sub
All help greatly appreciated, thank you!
Rachael