[AccessD] instr() - Need an exact match

John Skolits askolits at ot.com
Fri Sep 12 05:41:14 CDT 2003


That would work also but if there is only one value in the SearchIn string,
it would not have a comma. Still, a thought I did not think of.

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Erwin Craps
Sent: Friday, September 12, 2003 2:07 AM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] instr() - Need an exact match


Euh, you could also use this when you are sure the values are seperated
by a komma.


InStr(1,"a_Group,b_Group,c_Group" & "," , "c_Group" & "," ,c)

By adding the "," in bot strings you make the search string more unique.
You must be sure that no komma is used in the group names.

If you build the to be searched string yourself use chr(13) for as a
delimiter and replace the addedd "," by a chr(13).


vbBinaryCompare is only needed if you really wanna match.
This means a_group is NOT the same as a_Group

At my knowledge instr is much faster than strcomp.
So if you gonna have 10000 of iterations inst is faster.

Erwin



Erwin Craps

Zaakvoerder

www.ithelps.be/jonathan



This E-mail is confidential, may be legally privileged, and is for the
intended recipient only. Access, disclosure, copying, distribution, or
reliance on any of it by anyone else is prohibited and may be a criminal
offence. Please delete if obtained in error and E-mail confirmation to
the sender.

IT Helps - I.T. Help Center  ***  Box Office Belgium & Luxembourg

www.ithelps.be  *  www.boxoffice.be  *  www.stadleuven.be

IT Helps bvba* ** Mercatorpad 3 **  3000 Leuven

IT Helps  *  Phone: +32 16 296 404  *  Fax: +32 16 296 405 E-mail:
Info at ithelps.be

Box Office **  Fax: +32 16 296 406 **  Box Office E-mail:
Staff at boxoffice.be



-----Oorspronkelijk bericht-----
Van: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] Namens John Skolits
Verzonden: vrijdag 12 september 2003 4:06
Aan: Access Developers discussion and problem solving
Onderwerp: RE: [AccessD] instr() - Need an exact match


Gee, I didn't expect you guys to spend all that time on this but it is
greatly appreciated.

Function works as ordered.

Thanks!!
John


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Brett Barabash
Sent: Thursday, September 11, 2003 5:46 PM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] instr() - Need an exact match


So what you really need to do is compare the portion between the
delimiters (commas). Here is a function that illustrates this:

Public Function ExactMatch(ByVal strSearchIn As String, ByVal
strSearchFor As String) As Boolean

    Dim lngPos1 As Long
    Dim lngPos2 As Long

    lngPos1 = InStr(strSearchIn, strSearchFor)

    If lngPos1 > 0 Then
        lngPos2 = InStr(lngPos1 + 1, strSearchIn & ",", ",")

        If StrComp(Mid$(strSearchIn, lngPos1, lngPos2 - lngPos1),
strSearchFor) = 0 Then
            ExactMatch = True
        End If
    End If

End Function


-----Original Message-----
From: Heenan, Lambert [mailto:Lambert.Heenan at aig.com]
Sent: Thursday, September 11, 2003 4:34 PM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] instr() - Need an exact match


The trouble with just using strcomp that way is that it will give you a
false match if the search string contains the sought string like this

Searchstring = "ABCDE", SoughtString = "BC".

Your code will return 0 as the sought string is contained in the search
string, but John wants to find the exact string "BC" with only spaces,
commas or nothing either side of it.

Lambert

> -----Original Message-----
> From:	Brett Barabash [SMTP:BBarabash at tappeconstruction.com]
> Sent:	Thursday, September 11, 2003 5:25 PM
> To:	'Access Developers discussion and problem solving'
> Subject:	RE: [AccessD] instr() - Need an exact match
>
> Oops,
> That should read: StrComp(Mid([StringToSearch],InStr([StringToSearch],
> [SearchFor]),Len([SearchFor])),[SearchFor])
>
> But you get the idea...
>
>
> -----Original Message-----
> From: Brett Barabash [mailto:BBarabash at tappeconstruction.com]
> Sent: Thursday, September 11, 2003 3:57 PM
> To: 'Access Developers discussion and problem solving'
> Subject: RE: [AccessD] instr() - Need an exact match
>
>
> How about:
>
> StrComp(Mid(InStr([StringToSearch],
> [SearchFor]),Len([SearchFor])),[SearchFor])
>
>
> -----Original Message-----
> From: John Skolits [mailto:askolits at ot.com]
> Sent: Thursday, September 11, 2003 3:36 PM
> To: Access Developers discussion and problem solving
> Subject: RE: [AccessD] instr() - Need an exact match
>
>
> Here is a better example. In this case both function return a 1
>
>
> StrComp("SecGrp_Eng_Super, secGrp_Admin", "SecGrp_Eng_Super")
>
>
> StrComp("SecGrp_Eng_Super, secGrp_Admin", "SecGrp_Eng")
>
> The first one is an exact match, the second a partial match. I want to

> distinguish between the two.
>
>
>
>
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Heenan,
> Lambert
> Sent: Thursday, September 11, 2003 4:13 PM
> To: 'Access Developers discussion and problem solving'
> Subject: RE: [AccessD] instr() - Need an exact match
>
>
> I'm not clear on why InStr() does not suit your purpose.
>
> InStr("a_Group,b_Group,c_Group","c_Group") will return a non-zero
> value (17), meaning that "c_Group" was found in the first string. Now
> if you want an exact match that takes the case into account you can
> use...
>
> InStr(1,"a_Group,b_Group,c_Group","c_group",vbBinaryCompare)  ' note,
> must supply the start position - 1
>
> which will return zero as "c_group" is not found, whereas
>
> InStr(1,"a_Group,b_Group,c_Group","c_Group",vbBinaryCompare)
>
> returns 17.
>
> Lambert
>
> > -----Original Message-----
> > From:	John Skolits [SMTP:askolits at ot.com]
> > Sent:	Thursday, September 11, 2003 3:54 PM
> > To:	Access Developers discussion and problem solving
> > Subject:	[AccessD] instr() - Need an exact match
> >
> > Is there a way to do an exact match with something like Instr(). I
> > don't want a partial match.
> >
> > For example:
> > I have a string:    "SecGrp_Admin, SecGrp_Eng, SecGro_User"
> >
> > I want to look see if "SecGrpAdmin_Super" is in the string. Instr()
> > will return a value but I want an exact match.
> >
> > I know I can parse the string and look for an exact match based on
> > the parsed value. I just thought maybe there's a function I can use
> > that
> would
> > do an Exact match test.
> >
> > John Skolits
> >
> >
> >
> >
> > _______________________________________________
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> ----------------------------------------------------------------------
> ----
> --
> ----------------------------------------
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom
> they are addressed.
> If you have received this email in error please notify the
> originator of the message. This footer also confirms that this
> email message has been scanned for the presence of computer viruses.
>
> Any views expressed in this message are those of the individual
> sender, except where the sender specifies and with authority, states
> them to be the views of Tappe Construction Co.
>
> Scanning of this message and addition of this footer is performed by
> SurfControl E-mail Filter software in conjunction with virus detection

> software.
>
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> ----------------------------------------------------------------------
> ----
> ------------------------------------------
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom
> they are addressed.
> If you have received this email in error please notify the
> originator of the message. This footer also confirms that this
> email message has been scanned for the presence of computer viruses.
>
> Any views expressed in this message are those of the individual
> sender, except where the sender specifies and with authority, states
> them to be the views of Tappe Construction Co.
>
> Scanning of this message and addition of this footer is performed by
> SurfControl E-mail Filter software in conjunction with virus detection

> software.
>
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

------------------------------------------------------------------------
----
----------------------------------------
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they are
addressed. If you have received this email in error please notify the
originator of the message. This footer also confirms that this email
message has been scanned for the presence of computer viruses.

Any views expressed in this message are those of the individual sender,
except where the sender specifies and with authority, states them to be
the views of Tappe Construction Co.

Scanning of this message and addition of this footer is performed by
SurfControl E-mail Filter software in conjunction with virus detection
software.

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list