thelke
MIS
- Apr 9, 2002
- 84
This code requires a button, a list box, and a reference to Microsoft Office 10.0 Object Library. The button event OnClick is this code:
Private Sub cmdPlansPathButton_Click()
Dim fDialog As Office.FileDialog
Dim varFile As Variant
Me.PlansPath.RowSource = ""
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.AllowMultiSelect = False
.Title = "Please select a Folder"
If .Show = True Then
For Each varFile In .SelectedItems
Me.PlansPath.AddItem varFile
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub
I want this to go into a varchar field, but in order for the Listbox fieled to be recognized by the database(entered into the varchar field), I have to click on the field (did that make sense?). I need a way to make the data exist (the folder path) in code, so a user can browse for the path, hit OK in the browse window, and have the path appear in the table.
Thank you in advance for your help
Private Sub cmdPlansPathButton_Click()
Dim fDialog As Office.FileDialog
Dim varFile As Variant
Me.PlansPath.RowSource = ""
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.AllowMultiSelect = False
.Title = "Please select a Folder"
If .Show = True Then
For Each varFile In .SelectedItems
Me.PlansPath.AddItem varFile
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub
I want this to go into a varchar field, but in order for the Listbox fieled to be recognized by the database(entered into the varchar field), I have to click on the field (did that make sense?). I need a way to make the data exist (the folder path) in code, so a user can browse for the path, hit OK in the browse window, and have the path appear in the table.
Thank you in advance for your help