473,809 Members | 2,826 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Set multiselect property in VB

365 Contributor
Hello AGAIN

'Nother problem to solve....

im trying to set the MultiSelect property within VB for a list box, and i am using the code

Me.StaffHols.Mu ltiselect = True

and it wont work, it says that i cannot assign a value to the object, ive tried many ways to get this to work (and i have had this working before)

so what am i doing wrong?
Jan 28 '08 #1
43 3898
jaxjagfan
254 Recognized Expert Contributor
Hello AGAIN

'Nother problem to solve....

im trying to set the MultiSelect property within VB for a list box, and i am using the code

Me.StaffHols.Mu ltiselect = True

and it wont work, it says that i cannot assign a value to the object, ive tried many ways to get this to work (and i have had this working before)

so what am i doing wrong?
MultiSelect property is 0, 1 or 2
No Multi, Simple, or Extended
Jan 28 '08 #2
Dan2kx
365 Contributor
yeah i tried that as well same error
Jan 28 '08 #3
NeoPa
32,579 Recognized Expert Moderator MVP
I looked in the Help section and two things pop-out :
  1. It is only valid for ListBoxes. make sure it is such and not a ComboBox you're dealing with.
  2. It says it can only be changed when the form is in Design View. This seems strange for code, but may be worth delving into further.
Hope this helps.

PS. Valid values are only {0; 1; 2}. True is not valid. False, being equivalent to 0, is.
Jan 28 '08 #4
ADezii
8,834 Recognized Expert Expert
yeah i tried that as well same error
NeoPa has already pointed you in the right direction, but the Method to change the MultiSelect Property of a List Box while in an Active Form, is not that intuitive. Here is how it is done, let's say you are currently in frmMain and you wish to change the MultiSelect Property of lstMultiSelect:
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. Application.Echo False
  6.   DoCmd.OpenForm "frmMain", acDesign
  7.     Forms!frmMain![lstMultiselect].MultiSelect = conNONE
  8.                          'OR
  9.     Forms!frmMain![lstMultiselect].MultiSelect = conSIMPLE
  10.                          'OR
  11.     Forms!frmMain![lstMultiselect].MultiSelect = conEXTENDED
  12.                          'OR
  13.   DoCmd.OpenForm "frmMain", acNormal, , , acFormEdit
  14. Application.Echo True
Jan 29 '08 #5
Dan2kx
365 Contributor
Thanks for that, didnt realise i had to set the property in design view, you can do it from the properties menus whilst the form is active, bit odd isnt it.
had to do quite a lot of recoding to compensate for the form "closing and opening"

thanks again

Dan
Jan 29 '08 #6
NeoPa
32,579 Recognized Expert Moderator MVP
100 posts Dan - Nice :)
Just as a last point though, it may be worth checking to see if changes made in that state are saved to the form object. If so, you may have to ensure your code handles the situation.
Jan 29 '08 #7
Dan2kx
365 Contributor
Yeah thats one of the things i had to change, for some reason i think its good to "reuse" forms so i have lots or overly complicated code selections so after it has set the multiselect property it sets a value to 1 and then when the form closes (had to use a custom close button) it turns off again.


Got another question now..... same lines... i am using my multiselect in extended mode, so that someone can select a range (most importantly dates) and i want to assign the 1st and last selected (dates) in the list a to a VB variable

i have one idea which is to loop through the items selected and then state

if new value is > old lowest value (date) then set new low value / and similarly with the higher values. is there an easier way!?

Cheers again

ps. 101 now tehe
Jan 29 '08 #8
NeoPa
32,579 Recognized Expert Moderator MVP
Yeah thats one of the things i had to change, for some reason i think its good to "reuse" forms so i have lots or overly complicated code selections so after it has set the multiselect property it sets a value to 1 and then when the form closes (had to use a custom close button) it turns off again.


Got another question now..... same lines... i am using my multiselect in extended mode, so that someone can select a range (most importantly dates) and i want to assign the 1st and last selected (dates) in the list a to a VB variable

i have one idea which is to loop through the items selected and then state

if new value is > old lowest value (date) then set new low value / and similarly with the higher values. is there an easier way!?

Cheers again

ps. 101 now tehe
That's about how I'd do it too :) There is a collection of just the selected items of course.
(I'd only replace the "old lowest value" with lower ones though ;)).
Jan 29 '08 #9
Dan2kx
365 Contributor
OK this is how i did that then, seems to work!!

Expand|Select|Wrap|Line Numbers
  1. Dim sdt1 As Date, edt1 As Date, Loop1 As Integer
  2.     For Each row In Me.StaffHols.ItemsSelected
  3.         If Loop1 = 0 Then
  4.             sdt1 = Me.StaffHols.ItemData(row)
  5.             edt1 = Me.StaffHols.ItemData(row)
  6.         End If
  7.             If Me.StaffHols.ItemData(row) < sdt1 Then sdt1 = Me.StaffHols.ItemData(row)
  8.             If Me.StaffHols.ItemData(row) > edt1 Then edt1 = Me.StaffHols.ItemData(row)
  9.         Loop1 = 1
  10.     Next
  11.     'MsgBox "" & sdt1 & " " & edt1
  12.  
Now just have to spend HOURS duin something with that info HOURS i tell you (wont go into detail too boring)

Thanks again for you help

Dan
Jan 29 '08 #10

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

Similar topics

2
1921
by: Sally | last post by:
In a simple multiselect listbox, what is the code to return an item's index when it is selected? Thanks! Sally
2
3368
by: Cassie Pennington | last post by:
I am trying to write various items from a multiselect list box to an SQL statement to update a report, without success. SQL only appears to accept hard-coded data or control values from a form, not variable data. Any clues as to how I can write several items to an SQL statement from a multiselect listbox to update a report? Thanks in anticipation Cassie
1
5031
by: Danny | last post by:
I like the combo box because you can scroll through items nicely, but the list box just has the navigation where you can go up and down. I am trying to allow the user to multiselect items. With the list box, he does not like it because if he clicks on the nav bar, it loses the selection!! even if he holds down the shift. Is there a way to do this with a combo box? I just see the multi select for the list box. Thanks in advance
2
6078
by: Alan Lane | last post by:
Hello world: I'm using Access 2003. I have 2 listboxes. One is a single column. The other has two columns. I can use Dev Ashish's code (thanks Dev!) from the Access MVP Website to accumulate the values from the bound column of a MultiSelect listbox, so that I can include them in a SQL query that will then be the recordsource for a report. This gives me 2 of the 3 values I need to put into the SQL query. However, I can't get the non...
1
1985
by: tod4 | last post by:
Hi, My problem: I have query with value klient and product. On my form Im using multiselect box as filter of klient value. Now I would like to use second multiselect on this form for product value selection but only for those value that are filtered by first multiselect. I dont know how to connect selected value klient from first multiselect and value product from query and make it source of multiselect 2. Maybe someone did it before...
2
7962
by: Peder Y | last post by:
Anyone knows if there is some kind of property or function that will return the last selected/deselected item/index in a multiselect ListBox? SelectedIndex will point to first index in the SelectedIndices collection, so this is a dead end. My solution so far is to override the mouse click and key pressed events. However, since arrow up/down seems to keep a record of the item that currently has focus somehow, I would believe this...
0
1285
by: Peder Y | last post by:
I'm making an ownerdrawn multiselect multiextended ListBox where I'm calling the DrawItem event in my code on specific events and need to make my own DrawItemEventArgs. However, when do I need to pass on the "Focused"-property? The problem is that when I use the arrow keys to navigate the items, sometimes the FocusRectangle skips ahead or lags behind when I pass the Item over which the mouse hovers. Anyone knows how to find the focused...
2
1956
by: Steph | last post by:
I have created a multiselect list box control (lbx_comorb) that is populated from a datatable (dt_ptAdmission). The list box populates now problem at all. However the issue is when I load the webform, when there is already admission data. I need the populated list box (lbx_comorb) to show the items that were previously selected for this admission. The selected comorb data is stored in another datatable (dt_ptComorb). If anyone can...
5
2293
by: kimiraikkonen | last post by:
Hello, I have openfiledialog control named "openfileplaylist" and multi- selectpropert is TRUE. But although i select more than one files using "shift+arrows", i only get one file listed in my listbox. What's wrong? Code: If openfileplaylist.ShowDialog() = Windows.Forms.DialogResult.OK Then
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10375
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9198
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3860
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.