opening file dialog in VBA

Hi -
I am revamping a 6 year old app (never touched again on it...) for ms/access 64 bit and polishing interface, adding functionality and  ruggedising a bit. The app used to store documents in a master folder and a reference to them in the DB. In those days I used a function that I picked from some sample (maybe EE...), named  FileToOpen(searchFolder) that would show a dialog and, if the user selected a file would return the path to it, or an empty string.

Now in 64 bit, I did put the PtrSafe, but the function quickly (In a flash that we may see or not) just does nothing.

So I am asking it someone has an example similar to the function, that I could use in ms/access 2016 - 64 bit and (I can dream), I could also use to show the file inside a form? (namely for PDF files that would represent 90% of all files)
any help is welcome
João serras-pereiraAsked:
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.

Bill PrewIT / Software Engineering ConsultantCommented:
For the file selection part, I would recommend you use the standard Application.FileDialog capability in Access.  A couple of examples below, and should run on either 32 or 64 bit.

Juan OcasioApplication DeveloperCommented:
Here is code I used to do something similar:

Private Sub cmdSelectFile_Click()

    Dim strFileName As String
    Set fDialog = Application.FileDialog(DialogType:=msoFileDialogOpen)
    With fDialog
        .AllowMultiSelect = False
        .Filters.Add "Excel Workbook", "*.xlsx"
        .Filters.Add "Microsoft Excel", "*.xls"
    End With
    If fDialog.Show Then
        strFileName = fDialog.SelectedItems(1)
        Me.txtfileName.value = strFileName
    End If
End Sub

Open in new window

The Filter.Clear clears the filters and then I added filters for Excel.  It then selects the file path and saves it to a textbox called txtfileName

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
João serras-pereiraAuthor Commented:
Hi Thanks a lot!The 2nd part IO have sorted myself
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.