MS Access 2010 VBA Code Select from a ComboBox and open

How to use ms-access 2010 vba code case statement to select from a combobox and open a documents.
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.

You are going to need to give us more information.  How do you translate the value in the combo to the document name, for example?  If there is no translation and the combo box contains the exact file name including the full path, then just use the follow Hyperlink method.  FollowHyperlink works for ANY file type with a Windows association.   You don't have to know the software or its path.  Windows will figure it out.  It even works to open a web page if you give it a URL.

FollowHyperlink Me.cboDocName

If the combo does not contain the full path, you'll need some other code to figure it out.
Robert ShermanOwnerCommented:
Select Case Me!ComboBox

   Case condition_1
   Case condition_2
   Case condition_n

   Case Else

End Select

Open in new window

Jeffrey CoachmanMIS LiasonCommented:
Agree with Pat.

Typically you do not need case statements to open objects from a combobox.

So you will have to re-phrase your question in terms of what you ultimately need, ...not in terms of the way you think it should be done.
For example:
I want to  ____________
Then I want __________
...How do I accomplish this?

Other unknowns here are:
1. What, specifically, are these "Documents"
2. How are they stored?
3. What do you mean by "Open a Document"?

Are you selecting multiple "documents" ?, are document word documents?
If so, then you need a Listbox, ...not a combobox.
Then to open the multiple documents you would use code like this:

Dim vItm As Variant

    For Each vItm In Me.List0.ItemsSelected
        'Your Command to "open" the mysterious document(s), ...for example:
        Application.FollowHyperlink Me.List0.ItemData(vItm)
    Next vItm

Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

eddieb57Author Commented:
Hello Jeff,
The Documents are forms and contracts; Word docx and pdf format.
Are you saying that it is best to use a dropdown list to make multiple selections of the documents?

I will open the app and auto-fill the required fields.  I am using the bookmark method to name the fields in the Word documents.  I do not know how i can, call, open and fill the pdf forms fields.

Thank you for any assistance,
Looks like you started a new thread.  Please decide which one to keep and close the other.  In the one you keep, add a link to the closed one.
Jeffrey CoachmanMIS LiasonCommented:
I think the "new" thread was deleted by a mod.
Jeffrey CoachmanMIS LiasonCommented:
Let's not get ahead of ourselves.
First, a "dropdown", typically refers to a Cobobox. (where you can only make one selection.)
What I proposed was using a LIstbox, in which you CAN select multiple values.

Not sure about all of this "new" info:...
I will open the app and auto-fill the required fields.  I am using the bookmark method to name the fields in the Word documents.  I do not know how i can, call, open and fill the pdf forms fields.

...But in my proposal, you would open your form, select the documents in the listbox, then click a button to open all of the selected documents.
This seems to answer the crux of your original question:
select from a combobox and open a documents.

Here is a fully functioning sample database.
To test it, you will have to edit the file locations in the table, to be actual files on your disk.

Jeff was kind enough to create a sample database using the FollowHyperlink method I suggested.  However, your follow on question indicates that you don't want to simply open the documents but instead you want to fill fields in them.  That is a whole other problem and you would not use FollowHyperlink at all.  You would either use MailMerge or automation for Word and you would have to use automation for .pdf's but you would also need a full version of Adobe loaded on every computer that runs the app to form fill pdf's using automation.

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
Jeffrey CoachmanMIS LiasonCommented:
Agree with Pat.
If my very basic sample does what you want then you can split the points.
This is about all we can do in a singe question/thread
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.