IN THE SPOTLIGHT: MDE to MDB Conversion Service
(also supports: ACCDE to ACCDB, ADE to ADP, etc)
IN THE SPOTLIGHT: Access Database Repair Service
An in-depth repair service for corrupt Microsoft Access files
IN THE SPOTLIGHT: vbWatchdog
VBA error handling just got easier...
" vbWatchdog is off the chart. It solves a long standing problem of how to consolidate error handling into one global location and avoid repetitious code within applications. "
- Joe Anderson,
Microsoft Access MVP
Meet Shady, the vbWatchdog mascot watching over your VBA code →
(courtesy of Crystal Long, Microsoft Access MVP)
IN THE SPOTLIGHT: vbMAPI
An Outlook / MAPI code library for VBA, .NET and C# projects
Get emails out to your customers reliably, and without hassle, every single time.
Use vbMAPI alongside Microsoft Outlook to add professional emailing capabilities to your projects.
IN THE SPOTLIGHT: Code Protector
Standard compilation to MDE/ACCDE format is flawed and reversible.
Provided by allenbrowne.com, updated June 2006
This article describes an old technique of filling a list box via a callback function.
In Access 2000 and later, there is a newer technique that is more efficient and flexible.
To use the callback function:
Function DirListBox (fld As Control, ID, row, col, code) ' Purpose: To read the contents of a directory into a ListBox. ' Usage: Create a ListBox. Set its RowSourceType to "DirListBox" ' Parameters: The arguments are provided by Access itself. ' Notes: You could read a FileSpec from an underlying form. ' Error handling not shown. More than 512 files not handled. Dim StrFileName As String Static StrFiles(0 To 511) As String ' Array to hold File Names Static IntCount As Integer ' Number of Files in list Select Case code Case 0 ' Initialize DirListBox = True Case 1 ' Open: load file names into array DirListBox = Timer StrFileName = Dir$("C:\") ' Read filespec from a form here??? Do While Len(StrFileName) > 0 StrFiles(IntCount) = StrFileName StrFileName = Dir IntCount = IntCount + 1 Loop Case 3 ' Rows DirListBox = IntCount Case 4 ' Columns DirListBox = 1 Case 5 ' Column width in twips DirListBox = 1440 Case 6 ' Supply data DirListBox = StrFiles(row) End Select End Function
Home | Index of tips | Top |
Rate this article:
This is a cached tutorial, reproduced with permission.
Have your say - comment on this article.
What did you think of 'Listing Directory contents in a listbox / combo list'?
1. | Cate says... | 01 Apr 2008 |
Nice, simple piece of code. Any suggestions for sorting these files? |
2. | Wayne Phillips says... | 01 Apr 2008 |
Cate, This is not particularly efficient, but this code will do the trick: 'This Code Developed by Chris Vann (code adapted from http://www.freevbcode.com/ShowCode.asp?ID=3197) Then, just after the do loop in Allen's code, put:
|
iTech Masters | VAT: GB202994606 | Terms | Sitemap | Newsletter