Link to home
Start Free TrialLog in
Avatar of jking1234
jking1234

asked on

Select from Listbox in Access 2007

I load my listbox with the following code:
Private Sub Form_Load()
Dim fso As New IWshRuntimeLibrary.FileSystemObject
Dim fld As Folder
Dim fil As File
Me.lstFiles.RowSource = ""
Set fld = fso.GetFolder(gstrMediaFolder)
For Each fil In fld.Files
    Me.lstFiles.AddItem fil.Name
Next fil
End Sub

The listbox is filled with the names of the files in the folder but I cannot select an item and listindex appears to be stuck at -1
Avatar of TextReport
TextReport
Flag of United Kingdom of Great Britain and Northern Ireland image

Have you set the RowSourceType property to a Value List?
Cheers, Andrew
Avatar of jking1234
jking1234

ASKER

Yes that has been done
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Which was it?
;-)