In Access 2010 how would you write the file dialog commands to open a file and make a selection?

I wrote an application using Access 2003 that included the following commands in a module:

filenm = ""
commonDlg.Filter = "All Files (*.*)|*.*"
filenm = commonDlg.FileName

How would you rewrite these commands in Access 2010 using commands like the following:

   Dim fDialog As Office.FileDialog
   Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
   With fDialog  ...
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
Dim fDialog As As Office.FileDialog, filenm As String
   Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
   With fDialog
        .Title = "Select File"
        .InitialFileName = CurrentProject.Path
        If .Show Then
        filenm = .SelectedItems(1)
        End If

   End With

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Here are some examples

Public Function msoFileFolderBrowse() As Boolean

    With Application.FileDialog(3) ' 3=msoFileDialogFilePicker
    .InitialFileName = "C:\AccessFilesAllVersions"    ' start in this folder
        .AllowMultiSelect = False

        If .SelectedItems.Count > 0 Then
           MsgBox .SelectedItems(1)
        End If

    End With

'    With Application.FileDialog(3)  ' 3=msoFileDialogFilePicker
'        If .Show Then Debug.Print .SelectedItems(1)
'         more Code
'    End With

'    With Application.FileDialog(4)
'    .InitialFileName = "C:\SomeFolderName"    ' start in this folder
'        .AllowMultiSelect = False
'        .Show
'        If .SelectedItems.Count > 0 Then
'           MsgBox .SelectedItems(1)
'        End If
'    End With

'    With Application.FileDialog(4)  '4=msoFileDialogFolderPicker
'        If .Show Then Debug.Print .SelectedItems(1)
'        'more code
'    End With

End Function
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.