Solved

Combo box to select file names

Posted on 2011-02-18
12
1,042 Views
Last Modified: 2013-11-28
Looking for a way to have a combo box act like explorer searcing directories and when I identify a file to link to the record, click on it and it saves the link / file & path name
0
Comment
Question by:rogerdjr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34932691
Where is the combobox?

Sid
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34932874
aikimark: Is the combo in Access?

Sid
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34932907
But when I replied there was only "Microsoft Applications"?

Sid
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34932918
Maybe OP added 'Access' Later?

Sid
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34932922
Ah! How dumb of me? lolzzz

Yes I missed that. Thanks.

Sid
0
 
LVL 31

Accepted Solution

by:
Helen Feddema earned 500 total points
ID: 34933298
Here is some code to open a FileDialog object as a FilePicker, and save the selected file name to a textbox on a form:
Public Function SelectFile() As String
'Requires Office XP (2002) or higher
'Requires a reference to the Microsoft Office Object Library
'Created by Helen Feddema 3-Aug-2009
'Last modified 3-Aug-2009

On Error GoTo ErrorHandler

   Dim fd As Office.FileDialog
   Dim varSelectedItem As Variant
   Dim strFileNameAndPath As String
   
   'Create a FileDialog object as a File Picker dialog box.
   Set fd = Application.FileDialog(msoFileDialogFilePicker)
   
   With fd
      'Set AllowMultiSelect to True to allow selection of multiple files
      .AllowMultiSelect = False
      .Title = "Browse for File"
      .ButtonName = "Select"
      .Filters.Clear
      .Filters.Add "Documents", "*.doc; *.txt", 1
      .InitialView = msoFileDialogViewDetails
      If .Show = -1 Then
         'Get selected item in the FileDialogSelectedItems collection
         For Each varSelectedItem In .SelectedItems
            strFileNameAndPath = CStr(varSelectedItem)
         Next varSelectedItem
      Else
         Debug.Print "User pressed Cancel"
         strFileNameAndPath = ""
      End If
   End With
   
   SelectFile = strFileNameAndPath
   Me![txtFileName].value = strFileNameAndPath

ErrorHandlerExit:
   Set fd = Nothing
   Exit Function

ErrorHandler:
   MsgBox "Error No: " & Err.Number _
      & " in SelectFile procedure; " _
      & "Description: " & Err.Description
   Resume ErrorHandlerExit

End Function

Open in new window

0
 
LVL 16

Expert Comment

by:Sheils
ID: 34938561
The sample DB from this site should give you a good start:

http://www.lebans.com/callbackbrowser.htm
0
 

Author Comment

by:rogerdjr
ID: 34943570
Public Function SelectFile() As String

Works great - is there a way to "preset" the function so it starts at a selected path?

Thanks
0
 
LVL 46

Expert Comment

by:aikimark
ID: 34944470
Add a static string variable that contains the path.
Near the top of the routine check the length of the variable.  If = 0 then initialize it with a default path.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question