Access 2013: Perform action when a drop-down list item is selected in a form

Hello. I have a drop down list with some items in a form and I want when one of these items is selected, an action to be performed.

To be more specific, there is a list of dates that a person visited my office. When I select a date, I want a subform to open with the details of this (and only this) visit. If a select another date, I want to see the details of this other date.

How easy is this to be performed?

Any help will be appreciated.
Thanks for looking.
Who is Participating?
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.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
In the AfterUpdate event of the control, you would use the date from the control and the current visit PK as part of the WHERE argument for the open form:

Here's an example of constructing the WHERE argument first as as string, then opening a pop-up form to display data:

strWhere = "[InvoiceDate] = #" & Me.txtInvoiceDate & "# AND [CustID] = " & Me.cboCustID
DoCmd.OpenForm "frmDuplicates", acNormal, , strWhere, acFormReadOnly, acDialog


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
Anders Ebro (Microsoft MVP)Microsoft DeveloperCommented:
You can use the AfterUpdate event of the combobox to open a form
Private Sub ComboBox_AfterUpdate()
docmd.OpenForm formName:="MyForm",Wherecondition:="DateEntered=#" & me.combobox & "#"
end sub

Open in new window

AlfaDBAuthor Commented:
@Jim Dettman:

Used this code

Private Sub AptDateBox_AfterUpdate()

strWhere = "[AptDate] = #" & Me.AptDateBox & "# AND [Ptn_ID] = " & Me.cboPtn_ID
DoCmd.OpenForm "Frm_Ptns_Dates_Exams_EchoCard", acNormal, , strWhere, acFormReadOnly, acDialog

End Sub

where AptDateBox is the combo box caption, AptDate the name of the field in the table, txtAptDate is the name of the combo box Label and Ptn_ID the ID of the person.

I get an error for Me.txtAptDate : Method or data member not found

Any thoughts?
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

AlfaDBAuthor Commented:
Fixed some things. Now when I select a value from the combo, a pop-up window is asking

Enter paramete value:


There, I must write a value visit date in order to continue.

Any ideas?
AlfaDBAuthor Commented:
I get the same error with both solutions you provided (Jim Dettman & Anders Ebro)
Anders Ebro (Microsoft MVP)Microsoft DeveloperCommented:
Make sure that aptDate is part of the recordsource of the form you are opening.
AlfaDBAuthor Commented:
Hello again.

What I have succeeded so far.

The database refers to Patient Visits to my office and data collected in each visit.

The Frm_Ptn_VisitDate enters the Dates a Patient Visits my Office.

In the Frm_Testing I have a Form/Subform Configuration. If I select a Date in Combo17 (AptDate1 Label), it correctly changes the name of the Patient and the data collected in the specified date on the Subform.

1) What I can NOT do, is to have Combo17 show ONLY the dates a certain Patient visited my Office and not all the visits from all the Patients.

2) Another (better?) solution would be to create Cascaded Combo Boxes. For this cause I have added Combo19 from where you can select a Patient Name (I removed the duplicate values). Based on this Combo Box I would like Combo17 to show ONLY the dates this certain Patient visited my Office.

Thanks for your help. Waiting for your feedback.
AlfaDBAuthor Commented:
Found my way through it. Show the following video and helped too.
AlfaDBAuthor Commented:
Sorry guys. I am new to this. I didn't split the points correctly. Wanted to give you both 250 points...
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
No worries....

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.