Hi Phil,
Try this:
1.) Create a new form. Add a combo box control, and name it: cboFiles
2.) Add a command button. Name it: cmdRequery
3.) In form design view, press F4 to view the properties dialog, or click on
View > Properties, if it is not already displayed. Select the Event tab.
4.) Select your new command button. You should see it's name in the blue
title bar of the properties dialog.
5.) Click into the event that is labelled "On Click". Select [Event
Procedure] from the drop down list. Click on the build button (the small
button with three dots). You should see a form module open with four lines of
code:
Option Compare Database
Option Explicit '<---Add this line if you do not see it
Private Sub cmdRequery_Click()
End Sub
6.) Copy and paste the following code into your new form module:
Option Compare Database
Option Explicit
Private Sub cmdRequery_Click()
On Error GoTo ProcError
Dim strFolder As String
Dim strFile As String
Dim strFileList As String
strFolder = CurrentProject.Path & "\"
strFile = Dir$(strFolder & "*.gif")
strFile = Dir$(strFolder & "*.gif")
Do While Len(strFile) > 0
strFileList = strFileList & strFile & ";"
Debug.Print strFileList
strFile = Dir$
Loop
Debug.Print strFile
Me.cboFiles.RowSourceType = "Value List"
Me.cboFiles.RowSource = strFileList
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure cmdRequery_Click..."
Resume ExitProc
End Sub
7.) Click on Debug > Compile ProjectName
Note: ProjectName is a place holder for the name of your VBA project, which
is likely the same name as your database file.
8.) Save your changes. Open your form and test it by clicking on the command
button.
This code will only populate the combo box with the file names (not the file
paths), but it should serve as a starting point for you. A good reference
article for this type of thing is found here:
http://advisor.com/doc/16279
If you had to manually enter Option Explicit, then please refer to this link
to correct this problem:
Always Use Option Explicit
http://www.access.qbuilt.com/html/gem_tips.html#VBEOptions
Tom Wickerath
Microsoft Access MVP
http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________