Re: Populate a listbox with folder names
From: Graham Mandeno (Graham.Mandeno_at_nomail.please)
Date: 08/11/04
- Next message: Charlie Klein: "Getting Date field to automatically input current date"
- Previous message: Amir: "Automatic replication of a field from the previous record, using "F" key."
- In reply to: Robert: "Populate a listbox with folder names"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 12 Aug 2004 09:42:49 +1200
Hi Robert
Instead of reinventing the wheel, why not use the "Browse for folder" dialog
that is built into Windows?
You will find sample code at http://www.mvps.org/access/api/api0002.htm
If you also want to give the user flexibility in naming the file, as well as
selecting the folder, then try the built-in "File Save as" dialog (sample at
http://www.mvps.org/access/api/api0001.htm)
--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand
"Robert" <Robert@discussions.microsoft.com> wrote in message
news:45F80529-E334-4D42-8864-03A9691DB4C8@microsoft.com...
> I am writing code in Access that will open a printed to disk text file
with
> "Monarch", create a database file, append the database to a table, then
print
> a report based on that database.
>
> I need to open the text file each month from a different subfolder. I
want
> to read a folder and all its subfolders, populate a listbox so a person
can
> choose which folder/month they want to use.
>
> I have the following code, but cannot figure out how to populate the
listbox
> in access. Also the following code only lists the first record. Any help
> would be appreciated.
>
> Option Compare Database
> Option Explicit
> Private Sub Form_Open(Cancel As Integer)
> '----- NOTE: SET REFERENCE: "Microsoft Scripting Runtime" must be
> selected.
>
> '----- PURPOSE: List all Folders in a Sourcefolder
>
> Call ListFoldersInDirectory("F:\Dolars Reports\")
>
> End Sub
>
> Sub ListFoldersInDirectory(ByVal SourceFolderName As String)
>
> Dim FSO As Scripting.FileSystemObject
> Dim SourceFolder As Scripting.Folder
> Dim SubFolder As Scripting.Folder
> Dim oArray()
> Dim counter As Integer
>
> Dim i As Integer
>
> '----- PURPOSE: Lists the folders in SourceFolder
>
> Set FSO = New Scripting.FileSystemObject
>
> Set SourceFolder = FSO.GetFolder(SourceFolderName)
>
>
> ReDim oArray(SourceFolder.SubFolders.Count - 1)
>
> For Each SubFolder In SourceFolder.SubFolders
>
> List0.RowSource = SubFolder.Name
> Next SubFolder
>
>
>
> End Sub
> --
> Robert
>
- Next message: Charlie Klein: "Getting Date field to automatically input current date"
- Previous message: Amir: "Automatic replication of a field from the previous record, using "F" key."
- In reply to: Robert: "Populate a listbox with folder names"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|