NO_CARRIER
asked on
search column of listbox
Hi, I have a multicolumn listbox. It contains 4 columns.
How do I search if a word exists anywhere in column for.
something to the effect of...
if lstbox.columns(4) = "Yes" then msgbox ("There is the word 'Yes' somewhere in this column!")
How do I search if a word exists anywhere in column for.
something to the effect of...
if lstbox.columns(4) = "Yes" then msgbox ("There is the word 'Yes' somewhere in this column!")
In case you use it. I forgot to say that my code example uses uses DAO rather than the newer ADO. The DAO method will work fine, but DAO Objects 3.6 must be enabled under Tools | References in order for this code to function. If you need ADO, let me know.
ASKER
Hi Band... I don't think a select query would work in this instance, as the record itself hasn't actually been created at this point.
I have an unbound form with unbound controls. One of which is the multi-column listbox. Basically when I remove an item (or add an item), I need to know if any of the items in the 4th column have a certain property set to True. If it is true, then it will change the validation rules for eventually adding the record to the database...
I have an unbound form with unbound controls. One of which is the multi-column listbox. Basically when I remove an item (or add an item), I need to know if any of the items in the 4th column have a certain property set to True. If it is true, then it will change the validation rules for eventually adding the record to the database...
Okay, so the unbound form and controls is fine. I'm not sure what you're adding or removing from or to. But perhaps you can add code in the On Change or After Update property of the ListBox to check the value. Otherwise, perhaps you can attach a mdb file with just your form in it so I can see what you're doing, if that's possible.
ASKER
I have a listbox with 4 columns.
I have a series of comboboxes, and controls to add items to the listbox.
When the user clicks [Add Item] it will add items to the listbox.
When the user highlights an item and clicks [Remove Item] the item is removed from the listbox.
When the user has completed filling out the form and wanted to create the record they then click [Create Record], at which point I need to validate the 4th row of the listbox to see if any of the items have "True" listed. If any of the items have True, then my insert statement will be different.
The problem about checking when adding/removing items is there can be multiple items with True, all, or none. So I will need to check after the user has complied their list in the listbox.
I have a series of comboboxes, and controls to add items to the listbox.
When the user clicks [Add Item] it will add items to the listbox.
When the user highlights an item and clicks [Remove Item] the item is removed from the listbox.
When the user has completed filling out the form and wanted to create the record they then click [Create Record], at which point I need to validate the 4th row of the listbox to see if any of the items have "True" listed. If any of the items have True, then my insert statement will be different.
The problem about checking when adding/removing items is there can be multiple items with True, all, or none. So I will need to check after the user has complied their list in the listbox.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Dim MyValue As String
MyValue = CheckForRecords()
If MyValue = "True" Then
'Yes there are records, Do something
Else
'No records, do something else
End If
Open in new window