By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,248 Members | 1,961 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,248 IT Pros & Developers. It's quick & easy.

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

P: 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
Share this Question
Share on Google+
6 Replies


P: 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

Expert 100+
P: 634
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
Expert 5K+
P: 8,624
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

P: 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

P: 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
Expert 5K+
P: 8,624
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.