STILL CANT SUS THE COMBO TO LIST BOX (1 Viewer)

dubiousp

Member
Local time
Today, 07:12
Joined
Mar 6, 2020
Messages
86
Good afternoon I have been struggling a little with the list box being populated from combo selections. The below works well allowing me to select from a list of 50ish items then they subsequently add to the list box

The lookup list is is in one table called medication,

the lbdrugs list box is populated through a combo box that takes its data from the medication table.. My problem is linking the list box lbdrugs to a table where the selected records are held. Essentaiily a patient record

I think its because im selecting record source which of course chanes where it looks

Private Sub cgdrugadd_AfterUpdate()



Me.lbdrugs.AddItem (Me.cgdrugadd.Column(1))
Me.lbdruginfo.AddItem (Me.cgdrugadd.Column(2))


End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:12
Joined
Oct 29, 2018
Messages
21,471
Hi. Is this question related to this thread? If so, you never answered the question I asked you over there. Can you post a sample copy of your db with test data to help us understand better your situation/setup? Thanks.
 

dubiousp

Member
Local time
Today, 07:12
Joined
Mar 6, 2020
Messages
86
Appologies DB attached forgive me is quite messy as its the first attempt.. the basic for is the overall view what im trying to do is update the patient medication list from the list in pt meds
 

Attachments

  • CDM1R1.accdb
    3.8 MB · Views: 120

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:12
Joined
Oct 29, 2018
Messages
21,471
Appologies DB attached forgive me is quite messy as its the first attempt.. the basic for is the overall view what im trying to do is update the patient medication list from the list in pt meds
Hi. Thanks for posting your db. There's a few forms in there, which one has the issue?
 

dubiousp

Member
Local time
Today, 07:12
Joined
Mar 6, 2020
Messages
86
PT Meds so this takes its data from a table called medication, I did this because that table will update quite often.. The idea is that the list box then updates the patient record
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:12
Joined
Oct 29, 2018
Messages
21,471
PT Meds so this takes its data from a table called medication, I did this because that table will update quite often.. The idea is that the list box then updates the patient record
Hi. I'll take a look at that next. While I was poking around, I found your code in this form. Your code seems to be working fine for adding the combo selections to the listboxes.

1599409039810.png


PS. I don't see a PT Meds form. The one I posted above was called PTMEDS subform. So, I am guessing I was on the right track?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:12
Joined
Oct 29, 2018
Messages
21,471
Hi. I'll take a look at that next. While I was poking around, I found your code in this form. Your code seems to be working fine for adding the combo selections to the listboxes.

View attachment 84810

PS. I don't see a PT Meds form. The one I posted above was called PTMEDS subform. So, I am guessing I was on the right track?
Here is that form in Design View.

1599409186981.png


Since the Listboxes are both unbound, I don't imagine how you expect the values selected from it to be saved to the patient medication record.

It seems to me your problem is not with the code, but with the overall design of your db. How do you imagine the user using this form?
 

dubiousp

Member
Local time
Today, 07:12
Joined
Mar 6, 2020
Messages
86
Yes that is the correct form, it populates the list box but does not up date the PTMEDS record
 

dubiousp

Member
Local time
Today, 07:12
Joined
Mar 6, 2020
Messages
86
Each time I try to link the list box to the table to update records the list box stops working
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:12
Joined
Oct 29, 2018
Messages
21,471
Each time I try to link the list box to the table to update records the list box stops working
Hi. Which fields are you trying to use to bind the Listboxes? Also, what was the idea behind using a Combobox to populate the Listboxes? Will the user be selecting multiple meds for the patient, or just one?
 

dubiousp

Member
Local time
Today, 07:12
Joined
Mar 6, 2020
Messages
86
The user can select several medications for one patient,

The informtion should then update the PTMEDS table which is linked to the patient through the incident
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:12
Joined
Oct 29, 2018
Messages
21,471
The user can select several medications for one patient,

The informtion should then update the PTMEDS table which is linked to the patient through the incident
Okay, if that's the case, then you should consider using a continuous subform instead of a Listbox.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:12
Joined
Oct 29, 2018
Messages
21,471
What about going back to text boxes
Whether Listboxes or Textboxes, you can only store one medication at a time. Since you want to store multiple medications for the same patient, you'll need a separate table for it and use a continuous or datasheet form for data entry.

But still, you didn't answer my question again. Which fields were you trying to use to store the medications the user selects from the listbox (or combobox)?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:12
Joined
Oct 29, 2018
Messages
21,471
PTMEDS table Med_Name and Purpose
Okay, thanks for that. What about the other question on how come you decided to use a Combobox to populate the Listboxes? What did you expect/imagine would be doing or how they would be using that form? If we don't understand your database, it's hard to give you an exact solution to your problems.
 

dubiousp

Member
Local time
Today, 07:12
Joined
Mar 6, 2020
Messages
86
I only used the combo box as it seemed to be the easiest way to have searchable data I had not really given thought to anything else
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:12
Joined
Oct 29, 2018
Messages
21,471
I only used the combo box as it seemed to be the easiest way to have searchable data I had not really given thought to anything else
Hi. To see what I was trying to say, take a look at the new "medications" subform I added to your main form.
 

Attachments

  • CDM1R1.zip
    89.1 KB · Views: 128

dubiousp

Member
Local time
Today, 07:12
Joined
Mar 6, 2020
Messages
86
Hi. To see what I was trying to say, take a look at the new "medications" subform I added to your main form.

Yes that looks interesting certainly a more pleasurable way to enter data
 

Users who are viewing this thread

Top Bottom