prevent multiple selections in multiselect listbox

  • Thread starter steamngn via AccessMonster.com
  • Start date
S

steamngn via AccessMonster.com

Ok, So the subject sounds silly, but read on:
I have a form with a multiselect listbox of student ID's which is used to
launch various reports. There is one report which requires only one student
be selected. Is there a way to prevent a user from making multiple selections
in this listbox? I see that the Multiselect value cannot be changed unless in
design view, so that is out. Perhaps a way to count the number of selections
in the After Update and flag it if there is more than one for this report?
The reports are selected in a frame of buttons, so maybe:

If Me.Frame24 = 3 Then
If Me.List107.count of selected records >1 Then
msgbox "this would be ok code"
End If
End If

can something like this be done? Better ideas? Help!
Andy
 
F

fredg

Ok, So the subject sounds silly, but read on:
I have a form with a multiselect listbox of student ID's which is used to
launch various reports. There is one report which requires only one student
be selected. Is there a way to prevent a user from making multiple selections
in this listbox? I see that the Multiselect value cannot be changed unless in
design view, so that is out. Perhaps a way to count the number of selections
in the After Update and flag it if there is more than one for this report?
The reports are selected in a frame of buttons, so maybe:

If Me.Frame24 = 3 Then
If Me.List107.count of selected records >1 Then
msgbox "this would be ok code"
End If
End If

can something like this be done? Better ideas? Help!
Andy

Code the List box BeforeUpdate event:
If Me.Frame24 = 3 Then
If Me.ListBoxName.ItemsSelected.Count > 1 Then
MsgBox "Sorry, only 1 items can be selected."
Cancel = True
End If
End If
 
S

steamngn via AccessMonster.com

Fredg,
You are the man!
Happy New Year!
Andy
Ok, So the subject sounds silly, but read on:
I have a form with a multiselect listbox of student ID's which is used to
[quoted text clipped - 13 lines]
can something like this be done? Better ideas? Help!
Andy

Code the List box BeforeUpdate event:
If Me.Frame24 = 3 Then
If Me.ListBoxName.ItemsSelected.Count > 1 Then
MsgBox "Sorry, only 1 items can be selected."
Cancel = True
End If
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top