473,625 Members | 2,632 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Auto Select Items in Listbox based on Column value

28 New Member
Good Afternoon,

I'm trying to auto-select items in a multi-select listbox based on a column's criteria in a VBA Sub. Here is my code thusfar that fails. All values are text data type. Any suggestions? Thanks.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim lngRow As Long
  3. Dim lbvalue As String
  4.  
  5. With Me.ListBox
  6.         For lngRow = 0 To List489.ListCount - 1
  7.             If (Me.ListBox.Column(2, lbvalue)) = "OC" Then
  8.                 ListBox.Selected(lngRow) = True
  9.             Else
  10.                 'ListBox.Selected(lngRow) = False
  11.             End If
  12.         Next
  13. End With
  14.  
  15.  
  16.  
Mar 17 '14 #1
2 13082
pwag
28 New Member
Sorry. This line is incorrect
Expand|Select|Wrap|Line Numbers
  1. For lngRow = 0 To List489.ListCount - 1 
  2.  
It's really.
Expand|Select|Wrap|Line Numbers
  1. For lngRow = 0 To ListBox.ListCount - 1 
  2.  
  3.  
Mar 17 '14 #2
pwag
28 New Member
Just figured it out. Thanks.

Expand|Select|Wrap|Line Numbers
  1. Dim lngRow As Long
  2.  
  3. With Me.Listbox
  4.         For lngRow = 0 To Listbox.ListCount - 1
  5.             If (Me.Listbox.Column(2, lngRow)) = "OC" Then
  6.                     Listbox.Selected(lngRow) = True
  7.             Else
  8.                     Listbox.Selected(lngRow) = False
  9.             End If
  10.         Next
  11. End With
  12.  
  13.  
  14.  
Mar 17 '14 #3

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

Similar topics

3
26654
by: RRT | last post by:
I have an existing table which describes Streets and sections of streets between intersections: Table 1: Streets by Intersections Street Area Ann St. Main to Jackson Ann. St. Jackson To Summer Ann St. Summer to End Joe St. Aberdeen to Mike and so on for 1200 records
0
2645
by: Amber | last post by:
There are times when you will need to highlight or otherwise modify the contents of a particular DataGrid row-column value based upon the value in the column. In this example we will select the CompanyName, ContactName, and ContactTitle columns from the Customers table in the Northwind database. Whenever the value of ContactTitle equals "Owner" we will change the font color to red. We can do this by using an ItemTemplate where we have...
1
1823
by: David J | last post by:
Hi, I am trying again, and seriously struggling. My problem is that I am trying to set the selected value in a listbox equal to a value of a textbox, when you op the listbox. I am not getting that this is so hard to do, so I guess I am doing something wrong. Anyway here is the problem. Textbox1 has the value of "Accounting" now when I select the listbox which contains other departments I want "Accounting" to be pre-selected. I am using a...
8
2423
by: daddydfsu via AccessMonster.com | last post by:
I am trying to create a ListBox based on a search from a TextBox. I have a TextBox where I will enter in a MemberAlias. I want to click on a Search Button and that will do a select from a PersonData Table that I have filled out and look at each MemberAlias column for each Person on the Table. It will then retrieve any persons with that MemberAlias and populate it into a ListBox, where they can then select the record from that list box...
4
1864
by: ScarletPimpernal | last post by:
Hi Friends, Table ----- ID -- FId -- FVal ------------------ 1 -- 15 -- 0 2 -- 15 -- 1 3 -- 16 -- 0
4
13952
by: whamo | last post by:
I have the need to populate a field based on the selection in a combo box. Starting out simple. (2) tables tbl_OSE_Info and tbl_Input; tbl_OSE_Info has three fields: Key, OSE_Name and OSE_Wt tbl_Input has three fields: OSE_Job, OSE_Name, OSE_Wt I have populated tbl_OSE_Info table. I need to create a form that will store the data in tbl_Input I have racked my brain so much trying to figure out how to auto populate a field based on a...
2
6939
by: 6afraidbecause789 | last post by:
Hi - Has anyone ever used toggle buttons to select items in a listbox? I'd like to put about 24 toggle buttons on an unbound form that select or deselect items in a multiple select listbox. I've come across a way to set the listbox value to only 1 at a time, but need multiple toggle buttons to be on their corresponding listbox item values to be selected. Thanks!
1
1908
by: benwizzle | last post by:
So basically I have a gridview that is selectable. Below it I have a dropdownlist and a textbox. The dropdownlist has the options for each column in the row(I am using an ajax autocomplete extender that checks for related values in the textbox based of which dropdownlist value is selected.) I want to take that a step further and see if I can select a row based on what is in the textbox on the textchanged event. Right now im playing around with...
0
8182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8635
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
8352
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
8494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6115
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4085
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
4188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2614
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
1496
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.