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
Solved

Get file path using dialog open box

Posted on 2007-11-28
3
4,240 Views
Last Modified: 2013-11-28
I'm using MS Access VBA and would like to open a dialog open box, similar to MS Excel's "GetOpenFileName" function for the user to select a specific file.  I then would like to capture the complete path and store it in a local table.  My code is below, though I'm not sure why MS Access is not understanding FileDialog function:

Dim dlgOpen As FileDialog

Set dlgOpen = Application.FileDialog(FileDialogType:=msoFileDialogOpen)

With dlgOpen
    .AllowMultiSelect = False
    .Show
End With

Thanks,
Vishalarya
0
Comment
Question by:vishalarya
  • 2
3 Comments
 
LVL 33

Accepted Solution

by:
Jeroen Rosink earned 500 total points
ID: 20371591
Hello Vishalarya,

you might try something like:
flname = Application.GetOpenFilename( _
    Title:="Please select any file from the folder that contains the data, then click Open.")
If flname = False Then Exit Sub


the variable "flname" contains the selecte filename including path, you can use this for your object.

I hope this works for you
regards,
Jeroen
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 20371662
Hi vishalarya,

If you add a reference to MS Office (Tools > References), you can use that code, then get the selected path from the SelectedItems property....

    Dim dlgOpen As FileDialog
    Set dlgOpen = Application.FileDialog(msoFileDialogOpen)
    With dlgOpen
        .AllowMultiSelect = False
        .Show
        MsgBox .SelectedItems(1)
    End With

Regards,

Wayne
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 20371704
Umm, I thought this was for Access? GetOpenFilename doesn't work in Access.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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…

856 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