Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Access 2007: Limit number of selections in list box

Posted on 2011-02-14
4
Medium Priority
?
589 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

618 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