473,320 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Auto Select Items in Listbox based on Column value

28
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 12990
pwag
28
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
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
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...
0
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...
1
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...
8
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...
4
by: ScarletPimpernal | last post by:
Hi Friends, Table ----- ID -- FId -- FVal ------------------ 1 -- 15 -- 0 2 -- 15 -- 1 3 -- 16 -- 0
4
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...
2
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...
1
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.