Solved

MS Access - Listbox values

Posted on 2002-04-03
4
131 Views
Last Modified: 2010-05-02
Is it possible to save a users multiple selections in a listbox?  
I.E. I have a listbox with the following choices:
     Eastern
     Western
     Southern
     Northern

The multi-select property has been set to simple.

I want to be able to store the values selected by the user - so that when I return to the record, the users selections appear.

Thanks
0
Comment
Question by:debriggs
4 Comments
 
LVL 3

Expert Comment

by:Bahnass
ID: 6916788
if U Do it BOUND CONTROL ( ie set datasource,datafield Properties of normal combobox)

the dbase field will be integer saving index of combo
(ie 0,1,2,3)

U should then fill combo by programming (or even at design time in list property )

many other alternatives
1 use data combo with 2 tables
2 Do it all by prog (unbound control)

hope this helps
0
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 100 total points
ID: 6916877
Example:

Public db As DAO.Database
Public rs1 As DAO.Recordset

In a Form:

.
.
FilterString = " Where "
        For i = 0 To ListBox.ListCount
            If ListBox.Selected(i) = True Then
                FilterString = FilterString & " IndChain.IndChain = '" & Replace$(ListBox.ItemData(i), "'", "''") & "' OR "
            End If
        Next i

If FilterString = " Where " Then MsgBox "No items selected.", vbExclamation, "Select Items to Search": Exit Sub Else FilterString = Left(FilterString, Len(FilterString) - 3)
        DoEvents
        temp = "SELECT DISTINCTROW Coy.CoyName " & _
               "FROM Coy INNER JOIN (IndChain INNER JOIN CustIndChain ON IndChain.IndChainID = CustIndChain.IndChainID) ON Coy.CoyID = CustIndChain.CoyID " & _
               FilterString & _
               " ORDER BY Coy.CoyName "
        Set db = CurrentDb()
        Set rs1 = db.OpenRecordset(temp)
       
.
.

Hope this help too
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7642909
Hi debriggs,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept ryancys's comment(s) as an answer.

debriggs, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Expert Comment

by:kodiakbear
ID: 7673545
Moving the Question to the PAQ

kb
Experts Exchange Moderator
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now