Function to check all of tag property

radek225

Registered User.
Local time
Today, 06:40
Joined
Apr 4, 2013
Messages
307
I have a two controls
me.tekst61 - text box
me.imie - combo box
me.tekst61.tag = "2;5;7"
I need some function which can check that me.imie.column(4) equal to one of these "2;5;7" from me.161.tag property. if yes, then get msgbox "ok".
Can anyone help me?
 
Try InStr function..
Code:
If [URL="http://www.techonthenet.com/access/functions/string/instr.php"]Instr[/URL](Me.tekst61.Tag, Me.imie.Column(4)) <> 0 Then MsgBox "Found it"
 
doesn't work
 
Now it almost works. (Previously I done mistake)
Almost because when me.imie.column(4) = 3 and me.tekst61.tag = "12;13" then I got msgbox "Found it" but it's not truth
 
So your data is always going to be 12;13 and you want to find if the column value is going to be a number in the tag?

If so this calls for a custom function..
Code:
Public Function[COLOR=Red] findTag[/COLOR](strToSearch As String, strToFind) As Boolean
[COLOR=Green]'**********************
'Code Courtesy of
'  Paul Eugin
'**********************[/COLOR]
    Dim tmpArr() As String, iCtr As Long
    tmpArr = Split(strToSearch, ";")
    For iCtr = 0 To UBound(tmpArr)
        If strToFind = tmpArr(iCtr) Then
            findTag = True
            Exit Function
        End If
    Next
    findTag = False
End Function
Use the function as..
Code:
If [COLOR=Red]findTag[/COLOR](Me.tekst61.Tag, Me.imie.Column(4)) <> 0 Then MsgBox "Found it"
 
my ctrl.tag sometimes could be "12;13" sometimes "4;7" there's no rule.
Let's think about your first option. the page what you linked, has something like:

Code:
Instr ( [start], string_being_searched, string2, [compare] )
compare is optional. This is the type of comparison to perform. The valid choices are:
VBA Constant Value Explanation
vbBinaryCompare 0 Binary comparison

So If I do it like this:
Code:
If InStr(Me.Tekst61.Tag, Me.Imie.Column(4), [0]) <> 0 Then
MsgBox "Found it"
Ms access should know, that I want to binary search, Right? And then should correctly check values from tag property
 
Even if you do not use 0, it will still perform Binary comparison by default.. No difference will happen if you use vbBinaryCompare or 0..

Did you try the Code in Post#6?
 
78055466902746740506.jpg

Now I try understand, why ms access see an error (my previous post)
 
This is your previous post..
my ctrl.tag sometimes could be "12;13" sometimes "4;7" there's no rule.
Let's think about your first option. the page what you linked, has something like:

Code:
Instr ( [start], string_being_searched, string2, [compare] )
compare is optional. This is the type of comparison to perform. The valid choices are:
VBA Constant Value Explanation
vbBinaryCompare 0 Binary comparison

So If I do it like this:
Code:
If InStr(Me.Tekst61.Tag, Me.Imie.Column(4), [0]) <> 0 Then
MsgBox "Found it"
Ms access should know, that I want to binary search, Right? And then should correctly check values from tag property
And I hardly found any error description there.. What are you referring to?
 
I don't understand, why this code:
Code:
If InStr(Me.Tekst61.Tag, Me.Imie.Column(4), [0]) <> 0 Then
MsgBox "Found it"
doesn't work. Ms access has information that should check number because I use "[0]" but Ms access see some error with this code.
 
I don't understand, why this code:
Because it doesn't.. Sorry to be sarcastic, but as I mentioned there is no need to use the 0..

Even if you are going ahead in using that (which will cause absolute no difference) small error in your usage as well, you have enclosed the 0 in Square brackets.. You have to understand vbBinaryCompare only finds the Sort order if they are equal then it assumes they are the same.

What are you thinking of when you saw about Binary Compare?
 
You are welcome, BTW, the code in Post#6 would do what you want, it is a bit generic so it will be flexible to accommodate different search strings.. Good luck..
 

Users who are viewing this thread

Back
Top Bottom