How to use dlgbox common dialog box in MS ACCESS VBA?

I am trying to use dlgbox (common dialog box) to let the users select a file but none of the code works in my application.
Any thoughts?
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.

Patrick MatthewsCommented:
Seeing the code you are trying would be helpful :)
awarraicAuthor Commented:
I have tried tons and tons of diff code that I found over the internet.
Here's one sample code that I tried and didn't work.

Not sure if I am missing a class/object to add to make it work but Access doesn't seem to recognize cmdlgOpenFile at all.


Dim cmdlgOpenFile As New clsCommonDialog
Dim FileName As String    'full file name
Const clngFilterIndexAll = 5

cmdlgOpenFile.Filter = "Text Files (*.txt)|*.txt|DBF Files (DBF)|*.dbf|All Files (*.*)|*.*"
cmdlgOpenFile.FilterIndex = clngFilterIndexAll
'this is where the dialog opens

'returns your full file name.
FileName = cmdlgOpenFile.FileName

'hence no len, no name...
If Len(FileName) = 0 Then Exit Sub
Patrick MatthewsCommented:
Have you defined a class "clsCommonDIalog" in your VBA project?

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
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

awarraicAuthor Commented:
Might be silly question but... how do I do that?
Patrick MatthewsCommented:
You define a class by adding a class module.
awarraicAuthor Commented:
Ok, it's working... finally.... got all the stuff together.
This link was very helpful, just need to follow all the steps....
awarraicAuthor Commented:
thanks for the clue
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.