Access Access 2000 How to Select List Box Item on Form Open

Joined
Jul 19, 2013
Messages
1
Reaction score
0
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

' Check the Pen Availability list - criteria will be the same as originally used
With lstAvailablePens
' Run down the results
For intI = 0 To .ListCount - 1
If .Column(1, intI) = strPenId Then
' 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
Next
End With
End If
 
Last edited:
Back
Top