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

AlfaDB
AlfaDB used Ask the Experts™
on
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.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
President / Owner
Most Valuable Expert 2017
Most Valuable Expert 2012
Commented:
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

Jim.
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

Author

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?
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

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

Enter paramete value:

AptDate

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

Any ideas?

Author

Commented:
I get the same error with both solutions you provided (Jim Dettman & Anders Ebro)
Make sure that aptDate is part of the recordsource of the form you are opening.

Author

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.
SO_FAR.accdb

Author

Commented:
Found my way through it. Show the following video and helped too.

http://www.datapigtechnologies.com/flashfiles/combobox2.html

Author

Commented:
Sorry guys. I am new to this. I didn't split the points correctly. Wanted to give you both 250 points...
Jim Dettman (EE MVE)President / Owner
Most Valuable Expert 2017
Most Valuable Expert 2012

Commented:
No worries....

Jim.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial