judith,
I use the API method from
http://www.mvps.org/access/api/api0001.htm
(use it if you ever intend on using the code on a different machine or
version of Access). You can create a filter like "prod111???.doc" or
modify the filter as the data in the form changes.
However, I've never been able to get this code to lock the user into a
single directory. Therefore, I would suggest that you *not* use the
file dialog, but instead use a listbox or combobox that you fill with
the available filenames.
Air Code
'In a standard module
Public Function ListMatchingFilesForRowSource(strPath as String,
strPattern as String)
'assumes strPath ends with a backslash
Dim strResult as String
Dim strNextFile as String
'Call Dir with parameters. First match will be returned.
' "" will be returned if there is no match
strNextFile = Dir(strPath & strPattern)
Do Until strNextFile = ""
'prepend semicolon (rowsource delimiter
strResult = ";" & strNextFile
'call to Dir with no param. gives next match
strNextFile = Dir()
Loop
'Trim the leading semicolon
ListMatchingFilesForRowSource = Mid(strResult, 2)
End Function
USAGE:
Sub Form_OnCurrent()
Me.lstFileList.Rowsource =
ListMatchingFilesForRowSource(Me.YourPathField, "prod" &
Me.YourNumberField & "???.doc")
End Sub
-----------
You will have to replace YourPathField and YourNumberField, etc, with
actually field names or constants. You'll also need to run the code
that I put in OnCurrent in the AfterUpdate event of each control that
would change the pattern/rowsource.
Hope this helps,
Kevin