Use combo or list box to populate another list box

wpryan

Well-known Member
Joined
May 26, 2009
Messages
534
Office Version
  1. 365
Platform
  1. Windows
I am working on a CRM database for my company. We manufacture devices that are installed in clinics around the US. It is common that a doctor will use different machines in different locations. I want to be able to track this. To this end I made a table and associated form Doctors, and in this form I want to be able to have a list box to show which clinics (machines) the doctor is associated with. This data is coming from the Customer table, and I'll call it List Box A. I want the user to be able to select the clinic from a drop down or list box (List Box A), and have that selected item transfer to the list box in the Doctors table (List Box B). I have some experience with Excel VBA but it doesn't seem to be helpful with Access. I tried this code:
Code:
Private Sub cboAffiliatedClinic_AfterUpdate()
lboAffiliatedClinic.Value = cboAffiliatedClinic.Value
End Sub
where cboAffiliatedClinic is coming from the Customer table, and lboAffiliatedClinic is in the Doctors table, but it's not working. I also tried it in different events, with no luck. Any suggestions are greatly appreciated.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
If you want a doctor to be associated with multiple clinics then you would need to have a junction table which stores that association

DoctorID - Long Integer (FK)
ClinicID - Long Integer (FK)

and then you could use a listbox with the multi-select set to Simple or Extended but you would need code to add those to the table for that doctor. You would also need to include it in the form's On Current event.

I have to go to a meeting but here's a page which basically shows how you add a record from a multiple select listbox and then you might be able to see how you can read it back to the list box. If not, I'll be back later:

http://www.baldyweb.com/MultiselectAppend.htm
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top