Wildcard Seach of Combobox

jonnywakey

Registered User.
Local time
Today, 22:00
Joined
Feb 2, 2009
Messages
33
Hi All

I'm wondering if anyone can help me with some VBA?

I have a form which has a combobox called Task_Ref which looks up values in a table column.

I would like to be able to set the tickbox value of tickbox called P1 to True if the combobox contains the word "test", each entry on the combobox selection may vary such as:-

Test number 1
Yesterdays Test

As long as the word "Test" appears I would like the above to happen?

I was thinking of something along the lines of:-

If InStr(Task_Ref.Value, "Test") > 0 Then
P1.Value = True
Else
P1.Value = False
End If

End Sub

But this hasn't worked.

Any help would be appreciated.

Thanks

Jonny
 
So to be clear you are using this piece of code in the after update event of the ComboBox?
Code:
Private Sub Task_Ref_AfterUpdate()
    If InStr(Me.Task_Ref, "Test") <> 0 Then
        Me.P1 = True
    Else
        Me.P1 = False
    End If
End Sub
 
are you wanting only if the selected value in the combobox contains the word "test" or if any value that is available in it contains the word "test"?
 
pr2-eugin, thanks for the reply, Yes this is run on the AfterUpdate() event of the combobox.


TJPoorman, thanks also to you for the reply, ideally if any selected value in the selection contains "test"?

Thanks to you both for the support.

Jonny
 

Users who are viewing this thread

Back
Top Bottom