Select from Listbox in Access 2007

Posted on 2008-02-12
Medium Priority
Last Modified: 2008-02-13
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
Question by:jking1234
  • 2
LVL 28

Expert Comment

ID: 20874203
Have you set the RowSourceType property to a Value List?
Cheers, Andrew

Author Comment

ID: 20874421
Yes that has been done
LVL 74

Accepted Solution

Jeffrey Coachman earned 500 total points
ID: 20881213

Yeah, the same thing happens to comboboxes when any of these is true:
The form is being opened in Read Only mode (No edits allowed)
The Forms "Allow Edits" Property set to: No
The Listbox's "Locked" Property is set to: Yes

Check these as well

LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 20884461
Which was it?

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

I have had my own IT business for a very long time. I started mostly with hardware and after about a year started to notice a common theme. I had shelves with software boxes -- Peachtree, Quicken, Sage, Ouickbooks -- and yet most of my clients were…
Audit trails are very important in any system to hold people responsible for certain transactions and hold them to take ownership of their actions. This article is dedicated to all novice "Microsoft Access" developers.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question