473,385 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Change Listbox based on another field on a form

Hi...I am trying to get my listbox data to change based on a field on a form. Each time I click on the next record indicator at the bottom of the form, I would like the Listbox to change information. The control field is "Patient ID" and the listbox is "Patient Medications". When I go to the next Patient ID record I would like the Listbox to show the medications for that patient. Any ideas or direction on this would be really appreciated. It sounds like it should be easy to do, but for some reason the filters aren't working. I can get it to work on a subform, but that won't work for me in the long run.

Thanks!!!!
Sep 24 '07 #1
5 3847
ADezii
8,834 Expert 8TB
Hi...I am trying to get my listbox data to change based on a field on a form. Each time I click on the next record indicator at the bottom of the form, I would like the Listbox to change information. The control field is "Patient ID" and the listbox is "Patient Medications". When I go to the next Patient ID record I would like the Listbox to show the medications for that patient. Any ideas or direction on this would be really appreciated. It sounds like it should be easy to do, but for some reason the filters aren't working. I can get it to work on a subform, but that won't work for me in the long run.

Thanks!!!!
Are there Patients and Medications Tables linked by Patient ID, namely:
Expand|Select|Wrap|Line Numbers
  1. Patients.[Patient ID](1) ==> Medications.[Patient ID](MANY)
Sep 24 '07 #2
Yes they are linked as you show them. I have been able to get the listbox to show only the medications in the list for the first record now, but when I change to the next patient record the listbox stays the same with the information for only the first patient record.
Sep 25 '07 #3
ADezii
8,834 Expert 8TB
Yes they are linked as you show them. I have been able to get the listbox to show only the medications in the list for the first record now, but when I change to the next patient record the listbox stays the same with the information for only the first patient record.
Copy and Paste the following code to your Form's Current() Event and make any necessary Name substitutions:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.   Me![Patient Medications].RowSourceType = "Table/Query"
  3.   Me![Patient Medications].RowSource = "Select Medication From tblMedications " _
  4.                                        & "Where [PatientID]=" & Me![PatientID]
  5. End Sub
Sep 25 '07 #4
Thank you for the help, but it did not seem to work.

Basically, I have a query that pulls all of the information I need from multiple tables, and it contains the medication list for all patients. When I point to this query through a listbox from a form, I want to show only the medication list for the current patient id on the form. IE if I am looking at Patient 15's record, I only want to see the medications for patient 15 in the listbox. I have tried code and queries and joins and relationships and I just can't get the filter to work

I was up until 3:00am trying to figure this out...Please help, I know I am missing something little.

Thanks!
Sep 25 '07 #5
ADezii
8,834 Expert 8TB
Thank you for the help, but it did not seem to work.

Basically, I have a query that pulls all of the information I need from multiple tables, and it contains the medication list for all patients. When I point to this query through a listbox from a form, I want to show only the medication list for the current patient id on the form. IE if I am looking at Patient 15's record, I only want to see the medications for patient 15 in the listbox. I have tried code and queries and joins and relationships and I just can't get the filter to work

I was up until 3:00am trying to figure this out...Please help, I know I am missing something little.

Thanks!
Is [PatientID] a Text or Numeric Field?
Sep 25 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: N. Graves | last post by:
Hello... thank you for your time. I have a form that has a List box of equipotent records and a sub form that will show the data of the equipment select from the list box. Is it possible to...
2
by: Danny | last post by:
Hello I am trying to create a separate listbox and fill it with items based on what is in another field in a database. This field is bound to a field in the underlying database. But the data...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
15
by: NasirMunir | last post by:
I am trying to populate a listbox from another listbox on a access form. My first listbox has names of tables on a linked odbc databse. I am trying to display the tuples of the table in the second...
8
by: mlwerth | last post by:
Dear Access Group: This is the most basic and most embarrassing of questions, but I cannot find where to change the data type of a text field that I have in Access 2003 to a number field. I've...
7
by: EManning | last post by:
I'm using A2003 connected to a SQL 2000 backend. This is not an adp. I have a table which I store 0 and -1 for 2 bit fields. I have a listbox on a form based on a query of this table. The...
2
by: lhsiber | last post by:
I am new to access and am having a problem with filtering. Here is a little bit of my setup: I have a main form that has a listbox so that users can choose one or many groups in which to display...
4
by: onyris | last post by:
-------------------------------------------------------------------------------- Hi guys , have 2 questions if anyone can help me . first - have a form which displays all the records i have in...
7
by: onyris | last post by:
Hi guys, have a form which displays all the records i have in my database , and a search box for the user to search for a specific one . On the search button, i run a macro which opens another...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.