By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,661 Members | 1,917 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,661 IT Pros & Developers. It's quick & easy.

Adding data to a field from combo box

P: 4
I am creating a database for inputing ambulance run sheets. I have a table that lists different history conditions (HTN, CHF, Asthma....) In my main report form, I have a combo box that gets its' list from that table.

I want to be able to select from the list and then hit a command button next to it that adds the current data to another field, labeled history. I then want to be able to make another selection from the same combo box and add to that same history field without erasing what was there. If it's possible to add a comma between the selections, that would be beneficial too. I could live with spaces, which could be added in the original table.

So, the final field value would end up having multiple history data in one field, looking something like this------- Asthma, CHF, HTN,

I have figured out how to copy data from one field to another with the Me.xxx1 = Me.xxx2 script, but that overwrites what was there. I want to keep the current data and add to the list.

I'm sure this is possible, but have not been able to find info on how to accomplish this. I appreciate any help that can be given.

Thank you!!
Mike Busby
Dec 20 '07 #1
Share this Question
Share on Google+
10 Replies


missinglinq
Expert 2.5K+
P: 3,532
This should do it:

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourComboBox_AfterUpdate()
  2.   If IsNull(Me.History) Then
  3.    Me.History = YourComboBox
  4.   Else
  5.    Me.History = Me.History & "," & YourComboBox
  6.   End If
  7. End Sub
Welcome to TheScripts!

Linq ;0)>
Dec 20 '07 #2

Rabbit
Expert Mod 10K+
P: 12,365
That's not a good design for it however. You should have a another table that is related to this table that lists the illnesses for each person in a separate records.
Dec 20 '07 #3

missinglinq
Expert 2.5K+
P: 3,532
It really depends on what you're using it for, Rabbit. If you're going to want to manipulate the data, i.e. calculate how many patients with Asthma are transported, how many with COPD, etc. then yes, you'd be better off doing as you say. If the only point is generating a report of a single ambulance run, then a memo field box is just fine and what you suggest is overkill.

Linq ;0)>
Dec 20 '07 #4

Rabbit
Expert Mod 10K+
P: 12,365
It really depends on what you're using it for, Rabbit. If you're going to want to manipulate the data, i.e. calculate how many patients with Asthma are transported, how many with COPD, etc. then yes, you'd be better off doing as you say. If the only point is generating a report of a single ambulance run, then a memo field box is just fine and what you suggest is overkill.

Linq ;0)>
True, it would be overkill. I just like to plan for the worst. You just know someone's going to ask for that information at some point.
Dec 20 '07 #5

missinglinq
Expert 2.5K+
P: 3,532
But if everybody planned ahead, we would have just passed our 6ooth post, instead of our 60,000th post!

Linq ;0)>
Dec 20 '07 #6

P: 4
This should do it:

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourComboBox_AfterUpdate()
  2.   If IsNull(Me.History) Then
  3.    Me.History = YourComboBox
  4.   Else
  5.    Me.History = Me.History & "," & YourComboBox
  6.   End If
  7. End Sub
Welcome to TheScripts!

Linq ;0)>
I will try this code when I get back to work. If things go right, I will not return for another week.

I wouldn't expect that we would run a report on past medical illnesses, so this should be perfect. If we ran a report, it would be off of what the current illness is, and that would be another field (Chief Complaint) with a single entry.

Once again, I appreciate the feedback.

I hope you all have a Merry Christmas and Happy New Year.

God Bless!!

Mike Busby
Dec 21 '07 #7

Rabbit
Expert Mod 10K+
P: 12,365
I will try this code when I get back to work. If things go right, I will not return for another week.

I wouldn't expect that we would run a report on past medical illnesses, so this should be perfect. If we ran a report, it would be off of what the current illness is, and that would be another field (Chief Complaint) with a single entry.

Once again, I appreciate the feedback.

I hope you all have a Merry Christmas and Happy New Year.

God Bless!!

Mike Busby
That's what you think. $5 says someone will want that report within a year. Good luck though.
Dec 21 '07 #8

missinglinq
Expert 2.5K+
P: 3,532
Having run with volunteer and professional EMS agencies, in my youth, I suspect you're right, Mike, and chief complaints would be all anyone would be interested in! If you included all Dx the forests would be in more danger than there already are!

Have a great holiday!

Linq ;0)>
Dec 21 '07 #9

P: 4
This should do it:

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourComboBox_AfterUpdate()
  2.   If IsNull(Me.History) Then
  3.    Me.History = YourComboBox
  4.   Else
  5.    Me.History = Me.History & "," & YourComboBox
  6.   End If
  7. End Sub
Welcome to TheScripts!

Linq ;0)>
I used this code and it works great. I wanted to thank everyone for their input. It's sites like these that make the internet so valuable.

Mike
Jan 6 '08 #10

missinglinq
Expert 2.5K+
P: 3,532
Glad we could help!

Linq ;0)>
Jan 6 '08 #11

Post your reply

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