thelke
MIS
- Apr 9, 2002
- 84
Front End:Access 2002
Back End:SQL 2000
Here is what I am trying to accomplish. I want my users to be able to browse for a folder that holds a file, and click on that folder to enter it into the database as text.
I found this code. It requires a reference to the Microsoft Office 10.0 Object Library. It requires an unbound listbox with a valuelist.
I am referencing the Microsoft Office 10.0 Object Library
Private Sub cmdBrowseFolders_Click()
Dim fDialog As Office.FileDialog
Dim varFile As Variant
Me.UnboundListBox.RowSource = ""
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker) 'For Folders
With fDialog
.AllowMultiSelect = False
.Title = "Please select a Folder"
If .Show = True Then
For Each varFile In .SelectedItems
Me.UnboundListBox.AddItem varFile
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub
The issue now is this. I browse, and the value goes into the list box, but this value does not exist until I click on the listbox. I have the listbox invisible(for various reasons), but have a text box visible, and want the data to be moved from the listbox to the text box upon exiting the browse window. I need to do this with code instead of having the listbox visible, and having an OnClick() for the listbox (which works, I have tested it, but I need something that is EASY for my users). I tried implementing the DoCmd.GoToControl (Me.Textfield) (I saw this in another thread)but this is not working. How can I modify this code to do what I need? Please help. And know I am new to programing and VBA.
Thank you.
Back End:SQL 2000
Here is what I am trying to accomplish. I want my users to be able to browse for a folder that holds a file, and click on that folder to enter it into the database as text.
I found this code. It requires a reference to the Microsoft Office 10.0 Object Library. It requires an unbound listbox with a valuelist.
I am referencing the Microsoft Office 10.0 Object Library
Private Sub cmdBrowseFolders_Click()
Dim fDialog As Office.FileDialog
Dim varFile As Variant
Me.UnboundListBox.RowSource = ""
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker) 'For Folders
With fDialog
.AllowMultiSelect = False
.Title = "Please select a Folder"
If .Show = True Then
For Each varFile In .SelectedItems
Me.UnboundListBox.AddItem varFile
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub
The issue now is this. I browse, and the value goes into the list box, but this value does not exist until I click on the listbox. I have the listbox invisible(for various reasons), but have a text box visible, and want the data to be moved from the listbox to the text box upon exiting the browse window. I need to do this with code instead of having the listbox visible, and having an OnClick() for the listbox (which works, I have tested it, but I need something that is EASY for my users). I tried implementing the DoCmd.GoToControl (Me.Textfield) (I saw this in another thread)but this is not working. How can I modify this code to do what I need? Please help. And know I am new to programing and VBA.
Thank you.