Setting MultiSelect

Dreamweaver

Well-known member
Local time
Today, 19:54
Joined
Nov 28, 2005
Messages
2,467
I have a form where Under certain circumstances I would need to set A listbox Multiselect property to 0 from 1 in the after update of another listbox.


I have tried the above and also Me.Lst_Sales.Multiselect = 0 Which generates Error 2448 "Can't Assign A Value to this object"
 
Hm. It is extremely rare to change the Multiselect property of an existing list box DURING use. Rare enough that this is the first time I've heard of someone wanting to do it. Some background as to the purpose would be helpful. Rather than flat out saying, "that's not possible", let's see if we can understand the reason behind wanting to do it....
 
Hm. It is extremely rare to change the Multiselect property of an existing list box DURING use. Rare enough that this is the first time I've heard of someone wanting to do it. Some background as to the purpose would be helpful. Rather than flat out saying, "that's not possible", let's see if we can understand the reason behind wanting to do it....
Really Don't remember Using "That's not possible" Anywhere in my post I asked a simple question do you really want me to explain every design concept I have used in this project which Is running at over a 1000 hrs to date.
 
Per MS Docs: "This property can be set only in form Design view."
 
https://stackoverflow.com/questions...-form-view-from-single-form-to-continous-form

This works.

Private Sub Command15_Click()
Me.Dirty = False
DoCmd.RunCommand acCmdDesignView
Forms!Holidays.List0.MultiSelect = 1
DoCmd.RunCommand acCmdFormView
End Sub

I don't think George meant to imply you said "impossible" but error message "Can't Assign" did imply and asked for more info to possibly offer an alternative solution.
 
Last edited:
Really Don't remember Using "That's not possible" Anywhere in my post

I think George meant that rather than him (George) simply saying it wasn't possible, he was trying to get some background in order to come up with an alternative solution. He wasn't saying that you had said it.

Also, I'm not sure the code in post 6 will work if users have the runtime version or an accde. If that is a possibility, I'd test before going too far down that road.
 
I think George meant that rather than him (George) simply saying it wasn't possible, he was trying to get some background in order to come up with an alternative solution. He wasn't saying that you had said it.

Also, I'm not sure the code in post 6 will work if users have the runtime version or an accde. If that is a possibility, I'd test before going too far down that road.
Thanks @June7 But wont work for me As will be using a ACCDE, And may make the system over complicated so will use a test to see how many items have been added, I'll store each row in a local so I can unselect it should there be 1 item already selected.

hopefully that will work lol
 
Really Don't remember Using "That's not possible" Anywhere in my post I asked a simple question do you really want me to explain every design concept I have used in this project which Is running at over a 1000 hrs to date.
Sorry, I meant to say I don't think it's possible.... But rather than being pedantic, I would like try to understand why it's required and how you need to do it and maybe that way come up with an alternative that can be implemented.

But June7 did explain one possible how. Change the form to design view, change the property and change it back to form view. That would avoid the error, but it may not actually meet your needs since it does involve changing to design view, and changing back to form view will trigger other form events.
 
What I'm working on is a data Update, The Left list holds the Main Data That is to be updated Depending on Chart, Date, Twk and Lwk,
In most cases I will be able to use the select all as I would have made a visual check but sometimes I may need to match Items By selecting a Item in left list and one in Right List ("Sales"), I wanted to prevent more than one item from being selected which would cause problems.
After thinking about it the simplest way maybe to create a single select copy of the right hand list and set it below so when a item is selected in left list it hides the multiselect list and makes the Single select list visible and my code would test left list so it knows which function to run.

Hope that was understandable lol
2022-04-03 (2).png
 
The reason you can't swap the type on the fly is it changes the structure of the control. In single select case, the control is bound to a field of the form's RecordSource. in the multi-select case, it is not bound at all. You would need to write your own code to save and display the data. Access won't do it for you unless you use a multi-value field and that is the road to ruin. Don't even think that is what I am suggesting.
 

Users who are viewing this thread

Back
Top Bottom