Solved

Access 2007: Limit number of selections in list box

Posted on 2011-02-14
4
533 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 119

Accepted Solution

by:
Rey Obrero 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 119

Expert Comment

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

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

757 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

20 Experts available now in Live!

Get 1:1 Help Now