Solved

Access 2007: Limit number of selections in list box

Posted on 2011-02-14
4
577 Views
Last Modified: 2012-08-13
Hello, I have on a form several multiple selection list boxes (multi-select type extended) which several members of this website have helped me on.  The listbox has an afterupdate code which passes its selection onto the field [Reprint Edition]:

Private Sub List48_AfterUpdate()

With Me.List48
If .Selected(.ListIndex) = True Then
    If rst = "" Then
        rst = .Column(0, .ListIndex)
        Else
        If InStr(rst, .Column(0, .ListIndex)) = 0 Then
            rst = rst & ", " & .Column(0, .ListIndex)
        End If

    End If
   
    Else
    If InStr(rst, ",") > 0 Then
        If InStr(rst, .Column(0, .ListIndex)) = 1 Then
            rst = Replace(rst, .Column(0, .ListIndex) & ",", "")
        Else
            rst = Replace(rst, "," & .Column(0, .ListIndex), "")
        End If
        Else
        rst = ""
    End If
End If

End With
Me.[Reprint Edition] = rst
End Sub

I want to limit this to only 1 selection.  I tried setting the box type to no multi-select via the properties menu for the list box, but this resulted in none of the selections being transferred to [reprint edition].  Could anyone help edit the above code to make this work?

Thanks so much,
Bevo
0
Comment
Question by:Bevos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 34888847
try this codes

Private Sub List48_AfterUpdate()
Me.[Reprint Edition]=me.list48

end sub
0
 

Author Comment

by:Bevos
ID: 34888892
Hi Capricorn1 thanks for the comment.  I tried the code, but it results in the listbox selections not being passed onto [reprint edition].  Any thoughts?
0
 

Author Comment

by:Bevos
ID: 34888943
I got this to work by setting the list-box, multi-select property to none. Thanks Capricorn1
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34888954
post the codes that YOU are USING.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

688 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