473,405 Members | 2,444 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,405 software developers and data experts.

How do you enter multiple terms off a list into one field?

112 100+
I am using Access 2003. Does anyone know a way creating a field in a form that you can only accept data from a list to enter into it, but you can enter multiple entrees in the same field? For Example, I would click on the field and a list or 20 terms would come up. Then I click on a term and enter it into the field (like a combo box) but I can then click on the field again and enter a second term into my field with out deleting my first one. I want to be able to add at lest 4 or 5 different terms off the list to one field. What I am trying to do is create a field where there would be set terms that I could search for each record.

Anyone got any ideas?
Oct 5 '07 #1
10 2443
Scott Price
1,384 Expert 1GB
A multi-select listbox should allow what you are describing.

Have a look at this code snippet in our Articles section: To retrieve values from a multiselect listbox:

Regards,
Scott
Oct 5 '07 #2
Redbeard
112 100+
I am having troble with the Code for list boxs that you recomender? As I am new to coding in VB.

Dim valSelect As Variant
Dim strValue As String ' just used for the demonstration

For Each valSelect In Me.listboxName.ItemsSelected
strValue = strValue & "'" & Me.listboxName.ItemData(valSelect) & "', "
Next valSelect

' to remove trailing comma
strValue = Left(strValue, Len(strValue)-2)

Where do I put this code... is it conected to the List box as an event or just inserted in general code?
listboxName = this is name of my listbox
ItemsSelected = ?
ItemData = ?

Please help!
Oct 5 '07 #3
nico5038
3,080 Expert 2GB
You should use Access 2007 for such a multivalue field.
In the older versions I wouldn't store the data in one field, as you would have to code and de-code the field each time.
Assume fields 3, 5 and 7 are set, then when updating you would need to fill the multiselect listbox and set those values and after a change the new set would deen to be stored again :-(
Personally I just define an additional table with two fields (The ID of the maintable and the ID of the table holding the 20 choices) that's linked to the maintable. By using a linked subform Access will fill the maintable ID and using a combobox, the needed selection of the 20 choices can be added.

Getting the idea ?

Nic;o)
Oct 5 '07 #4
Redbeard
112 100+
Sorry I don’t really follow? Won’t this still result in me having a combo box (on my main form) that I can pick one and only one term from the terms table and enter into my the combo box in the main form? Can you explain farther?

Thanks
Oct 5 '07 #5
nico5038
3,080 Expert 2GB
Sorry I don’t really follow? Won’t this still result in me having a combo box (on my main form) that I can pick one and only one term from the terms table and enter into my the combo box in the main form? Can you explain farther?

Thanks
No, it will provide you with a subform where you can add as many terms as needed. (And removing terms will be possible too)
This will allow you to search all used terms by filtering this additional table.

You can compare this with adding one ore more products to an Order. These are also placed in an OrderDetail table. To find all orders with a specific product you can filter the Orderdetail table for the product. Guess you won't place all ordered products into the main Order table, so why storing your terms in one field...

Nic;o)
Oct 5 '07 #6
Redbeard
112 100+
Thanks for all the help so far Nic;o).

so why storing your terms in one field...
The database is of artifacts and photo’s kept by the museum that I work for. The main form currently has a field that is called “Classification” that is a combo box. When you click on it, it displays a list of terms that categorize the photos so that they are easier to search thought (like: People, Places, Rule, Streets…). However only one term per photo can be put in the combo box. The problem is that many photo’s need to be linked to more then one term, so if a search is done a photo could come up as “People” and as “Houses” if they have both in the photo. I need to have a list of terms that I can select from that when selected will enter into a field one after another. So my new “Classification” field could have up to 4 or more terms to search by.

What you are suggesting would take my to a sub-form ever time to fill in my terms? Is it not possible to have a list box that when you click a term off the list it adds it to a text box and will continue to add as many terms off the list as you click?
Oct 5 '07 #7
nico5038
3,080 Expert 2GB
As stated before, combining the terms into one field will require a "code" and a "de-code" of the applicable terms.
When searching on multiple terms, you'll need to filter on multiple values within that field.
Having them in a separate table will ease the searching (you can use for the WHERE clause e.g. Term IN ('house','horse') ). You can still use a multiselect listbox, but personally I prefer however to show all possibilities in a subform and have the user to check the ones applicable. Then the checked ones are stored in the relation table.
A checkbox is more "stable" and userfriendly as a multiselect list.

Getting the idea ?

Nic;o)
Oct 5 '07 #8
A multi-select listbox should allow what you are describing.

Have a look at this code snippet in our Articles section: To retrieve values from a multiselect listbox:
Expand|Select|Wrap|Line Numbers
  1. Dim valSelect As Variant
  2. Dim strValue As String ' just used for the demonstration
  3.  
  4.     For Each valSelect In Me.listboxName.ItemsSelected
  5.         strValue = strValue & "'" & Me.listboxName.ItemData(valSelect) & "', "
  6.     Next valSelect
  7.  
  8.     ' to remove trailing comma
  9.     strValue = Left(strValue, Len(strValue)-2)
  10.  
If I am right this code makes strvalue equal to the values that were selected in the multiselect list box right? Now how do I get that information into the right field in the right record say for example TOPPINGS
Oct 29 '07 #9
If I am right this code makes strvalue equal to the values that were selected in the multiselect list box right? Now how do I get that information into the right field in the right record say for example TOPPINGS
Never Mind...Figured it out Sorry.....
Oct 29 '07 #10
Scott Price
1,384 Expert 1GB
I've been away from the desk for the last two or three weeks, so sorry to not get back to your question sooner. Glad you got it figured out, though.

Regards,
Scott
Nov 21 '07 #11

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

Similar topics

15
by: M Smith | last post by:
I have a form I want to submit to itself. I want to be able to type in a list of numbers and submit the form and have that list show up on the same form under the text box I typed them into and...
2
by: Jen F. | last post by:
I have inherited a medical database in which there are multiple values stored in a single field (ie. "Current Conditions" field might contain 1-20 different conditions, separated by comma (ie....
3
by: Susan | last post by:
AccessXP When I use the wizard to create a form, all the textboxes are created with the Enter Key Behaviour of "New Line In Field". When I create the form manually the Enter Key Behaviour is...
0
by: Mike Kingscott | last post by:
Totally hacked off here. I've written a user control that contains a text box, a required field validator and a button (these being the cornerstone of a search facility), all as ASP.Net server...
6
by: guoqi zheng | last post by:
In a regular html form, when user press "enter" key, the form will be submitted. However, in ASP.NET web form, a form will only be submitted (post back) when a special button is clicked. Many...
6
by: Clark Sann | last post by:
Can someone help me understand what object should be used as the lock object? I've seen some programs that use Monitor.Enter(Me). Then, in those same programs, they sometimes use another object. ...
60
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
24
by: MichaelK | last post by:
Who knows how to prevent submitting a form on the press Enter button before all fields on the form are filled up. People just enter the first field hit Enter and it submits the form and doing...
3
by: Jake Barnes | last post by:
I'm researching the Enter key. This is for an Ajax chat application. The designer tells me that she wants people to be able to submit text simply by hitting the Enter key. She wants this to happen...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.