Hi
I have used access for some time, but for some reason cannot get VBA to mark a list box row as selected (yes I know about list.selected(n) = True). Below is my code - it is now on the Form Current event, but I have tried it in Form Open/Actrivate/Load with the same results. Basically I am passing a string from one form to another and have checked strPenId is correct and matches a list item. However, if I have the code below in place, the list is not populated. Without it the list appears ok. If I run a test using a button after the form is presented, the relevant list box row is highlighted. The list box is populated as a value list as part of the Form Load event.
' See if we have been supplied with search criteria and expected result
If fDoFind And strPenId <> "" Then
I have used access for some time, but for some reason cannot get VBA to mark a list box row as selected (yes I know about list.selected(n) = True). Below is my code - it is now on the Form Current event, but I have tried it in Form Open/Actrivate/Load with the same results. Basically I am passing a string from one form to another and have checked strPenId is correct and matches a list item. However, if I have the code below in place, the list is not populated. Without it the list appears ok. If I run a test using a button after the form is presented, the relevant list box row is highlighted. The list box is populated as a value list as part of the Form Load event.
' See if we have been supplied with search criteria and expected result
If fDoFind And strPenId <> "" Then
' Check the Pen Availability list - criteria will be the same as originally used
With lstAvailablePens
End IfWith lstAvailablePens
' Run down the results
For intI = 0 To .ListCount - 1
End WithFor intI = 0 To .ListCount - 1
If .Column(1, intI) = strPenId Then
' We have found the selected pen on the availability form
Next' We have found the selected pen on the availability form
' .Selected(intI) = True == This is commented out as it stops the list being populated???
' Set the count to exit the loop
intI = .ListCount - 1
End If' Set the count to exit the loop
intI = .ListCount - 1
Last edited: