Solved

Combo box to select file names

Posted on 2011-02-18
12
997 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
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
 
LVL 30

Expert Comment

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

Sid
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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 45

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

The canonical version of this article is on my web site here: http://iconoun.com/articles/collisions/ A companion presentation is available here: http://iconoun.com/articles/collisions/Unicode_Presentation.pdf
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now