changing a listbox multiselect setting

J

Jonathan Parminter

Hi, using access 2002 I don't seem to be able to change
the multiselect setting for a listbox at runtime. The line
is simply

lstResult.MultiSelect=1

Online help suggests that this is a read/write property.

Can I change this setting? if 'yes'... how?

Thanks
Jonathan
 
D

Dirk Goldgar

Jonathan Parminter said:
Hi, using access 2002 I don't seem to be able to change
the multiselect setting for a listbox at runtime. The line
is simply

lstResult.MultiSelect=1

Online help suggests that this is a read/write property.

Can I change this setting? if 'yes'... how?

The help file also says, a little further down the page, "This property
can be set only in form Design view."
 
Z

ZenoParadox

If you really needed it to be changed at Runtime, the only way would b
to have two separate list controls which looked identical, one with th
Multiselect setting on and the other off, and make one visible and th
other not, and switch between them if necessary. It'd be a hassl
though -- you'd have to keep track of which one was visible and thu
responsible for user information and it would be pretty messy
 
J

Jonathan Parminter

Thanks Dirk,
I knew I had to have missed something....

Any ideas or suggestions about how to change this setting
on the fly?

I have a form that allows users to select the record they
want to view/edit (or to create a new record). My idea was
to avoid duplicating this form when users want to select
records for reports. The form toggles from form edit
options to reporting options. I only want users to select
a single record for editting to aviod record locking
conflicts in a multiuser environment. However I want to
allow the selection of multiple records for reporting.

Cheers
Jonathan
 
D

Douglas J. Steele

As long as you're not using an MDE, you may be able to open the form in
Design mode, change the property and resave the form.
 
D

Dirk Goldgar

Jonathan Parminter said:
Thanks Dirk,
I knew I had to have missed something....

Any ideas or suggestions about how to change this setting
on the fly?

I have a form that allows users to select the record they
want to view/edit (or to create a new record). My idea was
to avoid duplicating this form when users want to select
records for reports. The form toggles from form edit
options to reporting options. I only want users to select
a single record for editting to aviod record locking
conflicts in a multiuser environment. However I want to
allow the selection of multiple records for reporting.

With some fancy coding, you may be able to leave your list box set for
multiselect but enforce "single-selectness" through code. A quick test
suggests that code along these lines might work:

'----- start of code -----
Dim mblnSingleSelect As Boolean ' at module level

Private Sub List0_AfterUpdate()

Static varLastSelected As Variant
Dim intI As Integer

If mblnSingleSelect Then
With Me.List0.ItemsSelected
Select Case .Count
Case 0
varLastSelected = Null
Case 1
varLastSelected = .Item(0)
Case Else
If Not IsNull(varLastSelected) Then
Me.List0.Selected(varLastSelected) = False
End If
varLastSelected = .Item(0)
End Select
End With
End If

End Sub

'----- end of code -----

It's about as far from thoroughly tested as you can get, so be warned.
 

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