ted.martin
Registered User.
- Local time
- Today, 09:39
- Joined
- Sep 24, 2004
- Messages
- 743
I am using the File Browse Dialog to select and store a file path.
Here is the full code
As the control is on a subform, when the File Browse module is called with
it errors - on the line below - with cannot find the form F-Jobs]![SF-Job Hyperlinks (interesting with the lack of [ and ] )
.... whereas this line does work
I would like to use the generic form of File Browse declaring the form and field as variables. Can anyone suggest a correction to my Calling Code?
Many thanks as always
Here is the full code
Code:
Public Sub FileBrowse(myForm As String, myControl As String)
' This requires a reference to the Microsoft Office 12.0 Object Library.
Dim fDialog As Office.FileDialog
Dim varFile As Variant
' Set up the File dialog box.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
' Allow the user to make multiple selections in the dialog box.
.AllowMultiSelect = False
' Set the title of the dialog box.
.Title = "Select a File"
' Clear out the current filters, and then add your own.
.Filters.Clear
'.Filters.Add "Access Databases", "*.MDB"
'.Filters.Add "Access Projects", "*.ADP"
'.Filters.Add "HTML Document", "*.htm*"
.Filters.Add "All Files", "*.*"
' Show the dialog box. If the .Show method returns True, the user picked at least one file.
If .Show = True Then
.Application.Forms(myForm).Controls(myControl).Value = .SelectedItems(1)
Else
Exit Sub ' Cancel clicked
End If
As the control is on a subform, when the File Browse module is called with
Code:
Call FileBrowse("[F-Jobs]![SF-Job Hyperlinks].Form", "JobHyperlink")
it errors - on the line below - with cannot find the form F-Jobs]![SF-Job Hyperlinks (interesting with the lack of [ and ] )
Code:
.Application.Forms(myForm).Controls(myControl).Value
.... whereas this line does work
Code:
Forms![F-Jobs]![SF-Job Hyperlinks].Form!JobHyperlink.Value = .SelectedItems(1)
I would like to use the generic form of File Browse declaring the form and field as variables. Can anyone suggest a correction to my Calling Code?
Many thanks as always