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

Copying values from a List Box into a Text Box

P: 23
Hello,
I am creating a database in Microsoft Access 2000. It's to store books and other resources, like a library database (just to give you a bit of a background). I have a field called "Subject". It's a text field. In there, you manually type in the subject(s) that that book relates to, for example Sports, Health, Sex Education, Careers, Citizenship, etc. However, it's a bit inefficient to have to manually type in these words.

However, I would like to arrange this so the subjects don't have to be typed in. I would like to have a list box on the form with all the subjects listed in it. Then when you click a subject in the list box, it will copy it into the 'subject' field. More than one subject needs to be selectable, sor example you may have a book that relates to... sex education and health and wellbeing, so I may want all three subjects to be copied into the subject field.

I want to keep the subject field as a text box, I only want the words from the list box copied and pasted into the subject field (preferably seperated by commas). (i.e. If I select Health and Drugs in the List Box I want to create, I want "Health, Drugs" to appear in the existing 'Subject' text box.

Hope somebody can help. If somebody does reply, please can you talk nice and s-l-o-w-l-y for me, I have a stinking cold and through my eyes watering I can barely see my monitor, let alone comprehend anything remotely complex! The answer may be simple, I have a feeling I may have some something simmilar in college before. But I can't find anything and I've searched the net and can't find an answer. I'd very much appreciate any help anybody can give.

Thanks, Robert.
Mar 10 '08 #1
Share this Question
Share on Google+
1 Reply


P: 23
I'm actually replying to my own question, I found an old database with what I needed in it. I thought I'd put the answer on here just incase anybody else was searching for it.

I put the following code into the on click procedure for the list box:
Expand|Select|Wrap|Line Numbers
  1. If Len(Nz(Me!Subject.Value)) > 0 Then
  2.     Me!Subject.Value = Me!Subject.Value & ", " & Me!List13.Value
  3. Else
  4.     Me!Subject.Value = Me!List13.Value
  5. End If
  6.  
This code copies the value selected in the list box into the text box, and if more than one is selected, they are seperated by commas.
Mar 15 '08 #2

Post your reply

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