I am trying to insert a list box into “frmPatients” with option to save multiple values using check boxes. tblPainLevel and tblCurrentPain have multiple valued check boxes. My attempt is shown in the lower right corner of the attached “frmPatients”. I have inserted a list box into the form but it doesn’t have the check boxes or does it let me save multiple values in a record. Like the tables do. Can you help, please?
Rick B
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
list box in form (access 2007)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » list box in form (access 2007)
- This topic has 56 replies, 7 voices, and was last updated 16 years, 8 months ago.
AuthorTopicrlbroerman
GuestAugust 5, 2008 at 3:33 pm #1771777Viewing 7 reply threadsAuthorReplies-
WSJezza
AskWoody Lounger -
WSjohnhutchison
AskWoody Lounger -
WSkentg
AskWoody LoungerAugust 7, 2008 at 1:18 am #1816549I don’t know if this helps but to get all the values, of lines that are selected in a list box, in earlier version to 2007 this code works
Dim varIndex As Variant
Dim strFilter As StringFor Each varIndex In lstBox.ItemsSelected
strFilter = strFilter & “, ” & lstBox.ItemData(varIndex)
‘ if the ID field is a string use this line instead of the previous line
‘ strFilter = strFilter & “, “”” & lstBox.ItemData(varIndex) & “”””
Next varIndexin this example it is just loops through the rows and concatenating the values of the selected lines into a string to pass to a report filter but you could write each value to a table.
In this example the multi select property of the list box is set to normal. -
WSGARYPSWANSON
AskWoody Lounger
-
-
-
rlbroerman
Guest -
WSjohnhutchison
AskWoody LoungerAugust 7, 2008 at 6:44 pm #1816554I have had a look in 2007, and I think we need to take a step back to clarify your table structure, and what you want to achieve, before we look at how to do it with a form and list box.
tblPainLevel is just there as a lookup table I believe. It does not need multivalues, and does not need to lookup a value list that is the same as its own contents. So change this table so it is just a plain list of values.
What is tblCurrentPain trying to record? and why do you want multiple values? At the moment it seems that each patient has multiple records in tblcurrentpain, and each of these has multiple values. If you really need multiple records, then I imagine you need some other field to distinguish them, such as a date field.
I don’t understand this – which does not make it wrong – but I want to be clear about it.As you know multivalue fields are new in 2007. I suspect that many developers are reluctant to use them (I certainly am) because the idea of multivalue fields is not consistent with relational design. I see them as a shortcut for people who can’t be bothered with (or don’t understand) proper design. They might work, but I would be worried that I might find later that I am restricted with what I can do with the data contained in the multivalued field.
-
rlbroerman
GuestAugust 8, 2008 at 12:44 pm #1816557I relent.
After numerous comments about not using a multivalue list box. I agree and will try to use a subform instead.
Originally I thought the multi value check box look like a good idea because the subforms that I had created seemed so mechanical and did not fit in with te rest of my form.
Got any ideas on how to make the subform more like the rest of the form?
Rick B -
WSjohnhutchison
AskWoody LoungerAugust 8, 2008 at 3:45 pm #1816558You have done the exact opposite of what I asked.
Before talking about what what type of forms/controls to use, get clear about the table structure you need, and what it all means.
I am not telling you not to use a mutlivalued field in a table (and perhaps displaying it with a list box) because I don’t yet understand what you are trying to do.
However, I am sceptical about the use of multivalued fields. -
rlbroerman
GuestAugust 8, 2008 at 6:44 pm #1816559JH,
Sorry, I guess I jumped ahead to try to use a subform instead of a list box.
I think what I want to do with Pain is what I have done with Current Medications subform in the attached Database.
Another question. How can I tell what tables, queries, and etc. are used in my database and which ones are superflous so that I can find out what is not necessary and get rid of them. I want to clean up my database and get rid of old non-used stuff.
Rick Broerman -
WSjohnhutchison
AskWoody LoungerAugust 8, 2008 at 10:57 pm #1816560You are still talking about forms instead of data.
You might say “I want to record the level of pain experienced by each patient at each visit. For pain I want to record the level of intensity, and whether it is constant or intermittent.”
Or perhaps you might say “For each patient the level of pain will be recorded periodically. Each time a recording is made, I want to record the date of the recording, the intensity of the pain, and whether it is constant or intermittent”
I am not saying that either of those is correct. I want you to say what you are trying to record.
I have not looked at your attachment yet, partly because I want a statement first, and partly because it is difficult for me to look at Access 2007 dbs. I need to get out and fire up a different computer.
Finding out what tables and queries are superfluous is not simple. The best option is to get a copy of Rick Fisher’s Find and Replace , and use the Cross-Ref search.and chose to “Only list unreferenced items”. It can be downloaded free, and used for 30 days without registration, but I think (but I am not sure) that Cross-ref searches are only available in the registered version.
-
rlbroerman
Guest -
WSjohnhutchison
AskWoody LoungerAugust 10, 2008 at 9:55 pm #1816563In that case fields for pain should be added to the Visits table, rather than creating a new table.
Each dimension of pain should be a separate field, with its own list of values to choose from.
I would have thought two fields would be enough.
So you don’t need any new forms at all -just a couple of fields added to the visits form. -
rlbroerman
GuestAugust 12, 2008 at 4:27 pm #1816564But this will allow me to save only one type of pain in each field.
I want to be able to save multiple pains ie “stabbing” and “sharp” for constant pain.
I’ve got a bigger problem. I tried to add a list box to a form and then open the form and the subforms have disappeared and I get the error”Reserved error(-3087)” Got any ideas?
Rick B -
WSjohnhutchison
AskWoody LoungerAugust 12, 2008 at 5:05 pm #1816565When you write out a statement describing the data you want to collect, it is import to specify if any of the fields mentioned need to hold multiple values, as that has a big impact on the design.
[indent]
I want to record the level of pain experienced by each patient at each visit and whether it is constant or intermittent and the type of pain
[/indent]
I thought that by breaking the description of pain into different dimensions you would only need one value for any one dimension.
But I don’t know enough about pain categorisation to know if that is true.One dimension is the Intensity of the pain. Another dimension is whether it is constant or intermittent. A third Dimension seems to be some more descriptive term such as “Stabbing” or “Sharp”, and I think it is here that you think you need multiple values.
The general principle is that whenever you need multiple values you move the data into a related table, and display it on a subform ( or if you prefer and use 2007, create a multi value field, and perhaps display it as a list box .)
So the visits table would have:
- a field for Pain Intensity (displayed as a combo box, with its own list of values)
- a field to describe the continuity of the pain (displayed as a combo box with its own list of values
[/list]Then I would create a new table tblVisitPainDescription – VisitPainDescrptionID autonumber, VisitID Number and PainDescrption. PainDescription would be displayed as a combo with its ow list of values.
These PainDescription would be displayed as a subform on the Visits form.If you prefer the multivalue field option, add PainDescription to the Visits table as a multivalue field, with its own list of values.
I don’t know about the other problem. It sounds like the form has become corrupted. What do you see in Design View? Can you remove the list box? Have you tried “compact and repair”?
-
WSGARYPSWANSON
AskWoody LoungerAugust 13, 2008 at 10:30 am #1816566Rick,
I have been following this string of posts and you basically have two options if you want to sore multiple pain values for a visit.
1. Using the Multivalue list, select the pain or pains a person has per visit and store that in the visit table. (I have attached your database modified slightly that does this) This stores your selected items in one field with commas between each selection. Open your patient form to see this.
2. Create a new table – lets call it TablePains. Fields are ID, VisitNumber, Pain. Link to visit table as a one to many on the visit id. Use a multi select listbox and after selecting the “pains”, use code to go though the data and write it to the table. This way, each selection is stored as a separate value linked to the visit.
Anyway, the attached database shows an example of number 1. HTH
-
rlbroerman
Guest -
WSGARYPSWANSON
AskWoody LoungerAugust 18, 2008 at 5:38 am #1816568Rick,
– Open your database and close all open forms.
– Open your sbfVisits form in design view
– Delete the current pain combo box
– Open the field list
– Select the Paid ID field and drag it into the form and the multivalue list will work as your properties on the Pain ID in the main table are set as a lookup and allows multivalues.You probably created the original combobox before setting your properties to allow for a multivalue field list so the combobox retained the original settings.
HTH
-
rlbroerman
Guest -
WSpatt
AskWoody Lounger -
WSGARYPSWANSON
AskWoody LoungerAugust 26, 2008 at 10:19 am #1816575Rick,
I stopped using switchboards a long time ago as I did not find them very useful. In prior versions of Access there was a limit to how many command buttons that could be used to trigger actions such that you would find people jumping from switchboard to switchboard.
You might find it much easier to create a form and then insert command buttons to do what you want. If you use the wizard, you could insert a command button that opens the report. FWIW, I would recommend staying away from switchboards. If you use a form, you can have the form open when the database opens so it looks like a switchboard.
Now to answer your question. The recordsource on the report is qryVisitsDate. As there is no object in the database with this name, you get the error message when trying to open the report as the recordsource does not exist.
HTH
-
rlbroerman
GuestAugust 27, 2008 at 7:18 pm #1816576Gary,
Works great, thanks a bunch.
I put pain into a text box in my report. The pain query has multiple pains seperated by commas but I only get one of the pains in my report. Got any ideas?
For another report I want to pick two variables ie SSN and visit date and print info from only that visit. How do I go abt that?
This is what I tried but it won’t compile ——strWhere = “[Soc Sec No] = ” & Chr(34) & Me.[ComboSSN] & Chr(34) & “” &
“[VisitDate] = ” & Chr(34) & Me.[VisitDate] & Chr(34) & “”
Thanks for the help.
Rick B -
WSHansV
AskWoody Lounger -
rlbroerman
Guest -
WSHansV
AskWoody Lounger -
rlbroerman
Guest -
WSHansV
AskWoody LoungerAugust 28, 2008 at 3:42 pm #1816584That was on the 28th, not on the 18th.
I’ve told you before (for example in post 707,176) that you shouldn’t store multiple values in a field.
-
WSjohnhutchison
AskWoody Lounger -
WSHansV
AskWoody Lounger -
rlbroerman
Guest -
rlbroerman
GuestAugust 28, 2008 at 4:00 pm #1816585Gary,
I tried this and it worked great but when I to put it into a report but I only got one pain of the multiple pains seperate by commas in my query qryVisits. Hansv said this would be a problem but since you are familiar with multivalued check boxes I thought you might be able to help.
Rick B -
WSGARYPSWANSON
AskWoody Lounger -
rlbroerman
Guest -
WSGARYPSWANSON
AskWoody Lounger
-
-
-
WSGARYPSWANSON
AskWoody LoungerAugust 6, 2008 at 12:43 pm #1816547The first step is you are going to need to modify the listbox to a multi-select listbox to be able to select multiple values.
In the form design view, select the properties of the listbox, go to the other tab and set the Multi Select row to extended. This permits you to select multiple values in your listbox. You still need to determine how to get the data where you want.
I am, unfortunately, lost in your description of where you want to write the selections to. Once you make your selections, do you plan to store them in a table linked to the patient ID or other?
This should give you a start. If you search the forum on multi select list boxes you will find many examples of how to get the data selected and store them. Post back if you are stuck.
WSGARYPSWANSON
AskWoody LoungerAugust 7, 2008 at 5:34 am #1816551Rick,
Check out the following link for a review on creating multivalue fields. HTH http://office.microsoft.com/en-us/access/H…=CH100645681033%5B/url%5D
-
rlbroerman
Guest -
WSGARYPSWANSON
AskWoody LoungerAugust 8, 2008 at 4:50 am #1816555Rick,
John brings up some good points. In looking at your current design, you input patient data into TblPatients. Then you use a one to many relationship to track visits in the table named Visits that is linked back to the patient table via the SocSecNo. Your table PainLevel is used as a lookup to select the PainLevel of the patient for the current visit.
If I understand your request, you want the ability to select one or many Pain Levels for the current patient visit and want to store the data selected. (Correct?)
The question is how to do this? Do you want to use a MultiValue field as the selection that stores the data in a string as choice 1, choice2, choice3? I would not do it this way as it would then be a little more difficult to get a count on patients with a particular pain as the stored data is stored as part of a string. If using a multiselect listbox, you can loop through the values and store the data in a table that links back to the visit table via the visit number and store each pain as a separate value. It would then be easy to use the “pains” selected for further analysis or querying.
Anyway, back to your question. How do you want to obtain the data – via a multivalue listing that stores the data in a string or a multiselect listbox that would store the individual records in a new table linked to the visit as a one to many relationship?
-
WSGARYPSWANSON
AskWoody LoungerAugust 8, 2008 at 5:19 am #1816556Rick,
One other question. Your form that has the listbox for pains is tied to the main patient form. Wouldn’t you want this listbox that selects pains to be tied to not only the patient but on a particular visit as I would assume that a patient could have different symptoms or pains on different visits.
The listbox for pains should be tied to the vist table. You might want to move this listbox to the visits form. Just something to think about.
-
WSHansV
AskWoody LoungerAugust 9, 2008 at 2:03 am #1816561> I think (but I am not sure) that Cross-ref searches are only available in the registered version
That is correct, that option is disabled in the free evaluation version, it only becomes enabled when you enter the registration key. The help file lists the extra features that are available in the registered version.
I’ve bought Find and Replace years ago and I find it well worth the modest price.WSjohnhutchison
AskWoody LoungerAugust 29, 2008 at 4:05 pm #1816589In the DB you posted there are required tables missing, some forms missing, but duplicate versions of other things.
When you post a db for others to look at make it easy by:
- Checking that it works
- Removing superfluous items
Your code for opening the report to a specific visit has two problems:
- You start a new in the middle of a line of code. If you need to start a new line, you must use the continuation character _ at the end of the line.
- visit date is not available on the form to use. Your combo is just a list of patients.
Your visits table has a primary key of visitID. If you want to open a report to a specific visit, use the ID to identify the visit rather than a combination of SSN and Date. If you use a combo box, the the ID number as a hidden first column.
-
rlbroerman
Guest -
rlbroerman
Guest -
WSjohnhutchison
AskWoody Lounger -
WSjohnhutchison
AskWoody LoungerAugust 29, 2008 at 9:15 pm #1816594Because you still have not deleted all the superfluous stuff, I don’t know what report you are trying to open from what form.
You say you want to open a report to a specific visit, but I can’t see any reports that are about one visit at a time. You have reports that list visits, and reports that are about patients, with visits in a subform.The form called “run old visitsreport” might be the one. The first combo should just list SSN numbers, and just have one column. The second should have two columns VisitID and Visit Date, (as it has), but only for patients whose SSN matches the other combo. Then the where condition just uses the hidden VisitID , which is the value of the combo box anyway.
Any report you open with a VisitID Where clause must include VisitID in its recordsource. Without that you get a parameter prompt.
-
rlbroerman
Guest -
WSjohnhutchison
AskWoody LoungerSeptember 1, 2008 at 4:47 am #1816604Here is a demo.
frmRunVisitReport has 2 combos. The first just displays SSNs. The second displays visits for the selected SSN. Visit Date is displayed, but the ID is hidden in the first column, so the ID is the value of the control. Whenever the SSN is updated, the second combo must be requeried, and cleared. This code is in its AfterUpdate event.
The command button opens a new report : rptVisitDetails that shows all the information about a specific visit.
The Pain field is added to that report as a combo box. This displays the multiple values as a comma separated list. I think that is what you want.I deleted other forms and reports to make the zip file small enough to post.
-
rlbroerman
GuestSeptember 9, 2008 at 7:24 pm #1816605 -
WSjohnhutchison
AskWoody LoungerSeptember 9, 2008 at 8:09 pm #1816606Rick
It is difficult for me to look at 2007 files so I have not looked at the attachment. I will if I have to.
When you use multivalued fields, you can add the .Value attribute for that field to the query. When you do that you get a separate record in the query for each of the many values.
Is that what is happening? -
rlbroerman
Guest -
WSjohnhutchison
AskWoody Lounger -
WSjohnhutchison
AskWoody LoungerSeptember 13, 2008 at 5:40 am #1816609You have lost me I’m afraid.
As I said a few posts ago, when you post a db for someone to look you need to take the time and trouble to make sure that what you are posting makes sense to other people.
- Take out what is not relevant to the question
- Put in what is relevant
- Make sure it works
[/list]I posted you a working demo, which was about opening a report from a form. It needed a form , a report and a query. What you have posted does not have any of the things , so what do you want me to look at?If you include just the PainID field from visits in a query, you will see the multivalued field in the resuts. If you join on that field to tblPainLevel, two things will happen:
- Visits with no pain will drop out of the results
- Visits with more than one pain value will appear more than once.
I think that is your problem, but I don’t know what query you need to fix,
-
-
-
rlbroerman
GuestAugust 29, 2008 at 9:09 pm #1816593JH,
I tried this, which is a great solution, but what I added to the code is strWhere = “[VisitID] = ” & Chr(34) & Me.[ComboSSNVD] & Chr(34) & “” but when I select an SSN and Visit Date in the combo box and press the command button to execute the above I get “Enter Parameter Value” for ” VisitID”
I have had this kind of problem but can’t remember how to solve it.
Can you help, please.
Rick B-
WSjohnhutchison
AskWoody Lounger
rlbroerman
GuestSeptember 14, 2008 at 7:05 pm #1816610-
WSjohnhutchison
AskWoody LoungerSeptember 14, 2008 at 7:47 pm #1816611The report copyofVisits gets its data from qryVisitsDate. Your visits table has 16 records, and so does qryVisitsDate, so I don’t see any problem there.
All of the visits in copyofVisits have different dates, so I can’t see what the problem is.The subreport uses qryvisits, which joins table visits to tblPainLevel. As I explained last time. This only finds the last visit, but if it has multiple values for pain, it will return a separate record for each pain value.
Is your problem with the main report or the subreport?
WSHansV
AskWoody LoungerOctober 17, 2008 at 2:11 am #1816613This thread has become very long, so I will lock it. The discussion has been continued in the thread starting at post 738,103.
Viewing 7 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
How to Assess the Quality of Cheap Dissertation Help? (Awaiting moderation)
by
lillylane
24 minutes ago -
Install Office 365 Outlook classic on new Win11 machine (Awaiting moderation)
by
WSrcull999
2 hours, 15 minutes ago -
Install Office 365 Outlook classic on new Win11 machine (Awaiting moderation)
by
WSrcull999
2 hours, 23 minutes ago -
re-install Windows Security
by
CWBillow
36 minutes ago -
WWDC 2025 Recap: All of Apple’s NEW Features in 10 Minutes!
by
Alex5723
4 hours, 17 minutes ago -
macOS Tahoe 26
by
Alex5723
38 minutes ago -
Migrating from win10 to win11, instructions coming?
by
astro46
5 hours, 29 minutes ago -
Device Eligibility for Apple 2026 Operating Systems due this Fall
by
PKCano
5 hours, 3 minutes ago -
Recommended watching : Mountainhead movie
by
Alex5723
17 hours, 49 minutes ago -
End of support for Windows 10
by
Old enough to know better
3 hours, 11 minutes ago -
What goes on inside an LLM
by
Michael Covington
2 hours, 15 minutes ago -
The risk of remote access
by
Susan Bradley
7 hours, 54 minutes ago -
The cruelest month for many Office users
by
Peter Deegan
14 hours, 27 minutes ago -
Tracking protection and trade-offs in Edge
by
Mary Branscombe
20 hours, 3 minutes ago -
Supreme Court grants DOGE access to confidential Social Security records
by
Alex5723
1 day, 2 hours ago -
EaseUS Partition Master free 19.6
by
Alex5723
3 hours, 18 minutes ago -
Microsoft : Edge is better than Chrome
by
Alex5723
1 day, 15 hours ago -
The EU launched DNS4EU
by
Alex5723
2 days, 4 hours ago -
Cell Phone vs. Traditional Touchtone Phone over POTS
by
280park
1 day, 18 hours ago -
Lost access to all my networked drives (shares) listed in My Computer
by
lwerman
2 days, 10 hours ago -
Set default size for pasted photo to word
by
Cyn
2 days, 16 hours ago -
Dedoimedo tries 24H2…
by
Cybertooth
2 days, 4 hours ago -
Windows 11 Insider Preview build 27871 released to Canary
by
joep517
3 days, 15 hours ago -
Windows 11 ad from Campaign Manager in Windows 10
by
Jim McKenna
1 day, 7 hours ago -
Small desktops
by
Susan Bradley
8 hours, 36 minutes ago -
Totally disable Bitlocker
by
CWBillow
2 days, 8 hours ago -
Phishers extract Millions from HMRC accounts..
by
Microfix
3 days, 12 hours ago -
Windows 10 22H2 Update today (5 June) says up-to-date but last was 2025-04
by
Alan_uk
4 days, 18 hours ago -
Thoughts on Malwarebytes Scam Guard for Mobile?
by
opti1
2 days, 13 hours ago -
Mystical Desktop
by
CWBillow
4 days, 22 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.