Hi,
I needed to do this very same thing. The way I did it was to start by capturing the file names on a particular path, then loading those to a temporary table, then opening a continuous form, and having a button next to each file name for them to select the value and push it to the table or text box.
Here is how I started:
On the form, I put a button to list files, and then used this code on the button's On Click event:
'=====
Private Sub Command0_Click()
Dim filesys As Variant
Dim demofolder As Variant
Dim fil As Variant
Dim filecoll As Variant
Dim filist As Variant
Dim rs As Recordset
Dim db As Database
Dim stFirstName As String
Dim stLastName As String
Dim stName As String
Dim stDocName As String
Dim stLinkCriteria As String
Dim stSSN As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblLocalFile", dbOpenDynaset)
Set filesys = CreateObject("Scripting.FileSystemObject")
Set demofolder = filesys.GetFolder("I:\EnvHealth\ACCESS\Data\Scanne dDocuments")
Set filecoll = demofolder.Files
For Each fil In filecoll
rs.AddNew
rs!LocalFile = fil.Name
rs.Update
Next
stDocName = "frmLocalFileList"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub
'=====
The form frmLocalFileList was a continuous form based on the table tblLocalFile, and next to the text box in the continuous form I put another button. Unfortuantely I never got as far as inserting the data from this field, but another poster may get you that far. I ended up automatically associating files to records using a foreign key table so that more than one file could be associated with the patient, in this case.
If you are putting these file associations in NEW records (for example in a linked table,) then repost and I will show you that code modified to take the manual selection. Remind me that we will want to add code in that process to dump the contents of the temp table (tblLocalFile) after the update to prevent dupes.
HTH
mmcdonal
|