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
Solved

Access 2007: Limit number of selections in list box

Posted on 2011-02-14
4
561 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
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

839 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