469,610 Members | 1,773 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,610 developers. It's quick & easy.

Setting the multi select property of a list box in vba?

41
Is it possible to adjust the multi select property of a list box using VBA?

my initial thaught would be

Me.List43.multi select = simple

but this produces an error.
Jan 11 '08 #1
6 11880
Craggy
41
I have discovered that the way to set this particular property is:

Me.List43.MultiSelect = 1

however, this tells me that "You cant assign a value to this object"

Is it not possible to change the value of Multi Select on a list box?

this will seriously mess my project up if you cant since I need to be able to have the option to select one, or many for a list box.

I could probably get round this by having both a multiselect and a single select box on the form overlapping eachother, and hide the un-needed one so that only the needed one appears and is usuable, but this seems a little long winded for something that seems quite basic.
Jan 11 '08 #2
MikeTheBike
637 Expert 512MB
I have discovered that the way to set this particular property is:

Me.List43.MultiSelect = 1

however, this tells me that "You cant assign a value to this object"

Is it not possible to change the value of Multi Select on a list box?

this will seriously mess my project up if you cant since I need to be able to have the option to select one, or many for a list box.

I could probably get round this by having both a multiselect and a single select box on the form overlapping eachother, and hide the un-needed one so that only the needed one appears and is usuable, but this seems a little long winded for something that seems quite basic.
Hi

Extract from Access Help
Note You can set the MultiSelect property by using the list box's property sheet, a macro, or Visual Basic.

This property can be set only in form Design view.
So you can set it in code, but only with the form in design state ??

MTB
Jan 11 '08 #3
ADezii
8,800 Expert 8TB
I have discovered that the way to set this particular property is:

Me.List43.MultiSelect = 1

however, this tells me that "You cant assign a value to this object"

Is it not possible to change the value of Multi Select on a list box?

this will seriously mess my project up if you cant since I need to be able to have the option to select one, or many for a list box.

I could probably get round this by having both a multiselect and a single select box on the form overlapping eachother, and hide the un-needed one so that only the needed one appears and is usuable, but this seems a little long winded for something that seems quite basic.
You can change the Value of the MultiSelect Property, but it is not exactly intuitive how to do so:
  1. It can only be changed in Design Mode.
  2. You must use the Absolute Reference to the List Box as in:
    Expand|Select|Wrap|Line Numbers
    1. Const conNone As Integer = 0
    2. Const conSimple As Integer = 1
    3. Const conExtended As Integer = 2
    4.  
    5. DoCmd.OpenForm "Form1", acDesign, , , , acHidden
    6.   'Forms!Form1!lstMultiSelect.MultiSelect = conNone
    7.                         'OR
    8.   'Forms!Form1!lstMultiSelect.MultiSelect = conSimple
    9.                         'OR
    10.   'Forms!Form1!lstMultiSelect.MultiSelect = conExtended
    11. DoCmd.OpenForm "Form1", acNormal, , , acFormEdit, acWindowNormal
  3. Any other questions, feel free to ask.
Jan 11 '08 #4
Craggy
41
Yea, i read that and it seemed a little strange.

Im not sure why you would program the state of an object using vba while your in edit mode.

I resorted to having the 2 list boxes overlapping, it works fine but seems a little unecesary...
Jan 11 '08 #5
Craggy
41
Thanks ADezii,

unfortunately havign it change only when in design is not useful for this particular application. i managed a work arround though so its ok.

The more I use access VBA the more i think its unecesarily complicated.
Jan 11 '08 #6
ADezii
8,800 Expert 8TB
Thanks ADezii,

unfortunately havign it change only when in design is not useful for this particular application. i managed a work arround though so its ok.

The more I use access VBA the more i think its unecesarily complicated.
Thanks ADezii,

unfortunately havign it change only when in design is not useful for this particular application.
You are quite welcome. Just for curiosity, why would you want to dynamically change the MultiSelect Property, and why isn't it usefull for your particular Application?
Jan 11 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by ColinWard | last post: by
5 posts views Thread by Matthew Wells | last post: by
6 posts views Thread by dbuchanan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.