Microsoft KB Archive/98227

= ACC: Explanation of &quot;Option Compare Database&quot; Statement =

Article ID: 98227

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Access 1.0 Standard Edition
 * Microsoft Access 1.1 Standard Edition
 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition

-



This article was previously published under Q98227



Moderate: Requires basic macro, coding, and interoperability skills.



SUMMARY
The description of the Option Compare Database statement in the Microsoft Access &quot;User's Guide&quot; is not very clear. The following is the description from the guide:

Comparison is based on the characters' relative position according to the sort order specified when the database was created or compacted.



MORE INFORMATION
The Option Compare statement can be used to make comparisons based on binary value, text value, or values that are defined in the Options dialog box. (To modify the Options dialog box, click Options on the View menu.)

For example, if you use the Option Compare Binary statement, the expression &quot;a&quot; > &quot;Z&quot; would be true, because the ASCII value of &quot;a&quot; is greater than the ASCII value of &quot;Z&quot;. However, if you use the Option Compare Text statement, the expression would be false, because &quot;Z&quot; comes after &quot;a&quot; in the alphabet. If you use the Option Compare Database statement, the expression will be true or false depending on the New Database Sort Order setting you select in the Items box of the Options dialog box.

The Option Compare statement can also affect the results of the Instr function. For example, the following function finds the first tab character in a string: Function FindTab (mystr$) FindTab = InStr(1, mystr$, Chr(9)) End Function

If mystr$=&quot;1 abc ABC&quot;, the InStr function will return the following results, depending on which Option Compare statement is used:

Option Compare Database: 2 Option Compare Text:    6 Option Compare Binary:  6 For another example, the following function returns the position of the first uppercase 'c' in the string: Function FindEm (mystr$) FindEm = InStr(1, mystr$, &quot;C&quot;) End Function If mystr$=&quot;1 abc ABC&quot;, the function will return the following results, depending on which Option Compare statement is used:

Option Compare Database: 5

Option Compare Text: 5

Option Compare Binary: 9

Keywords: kbprogramming KB98227

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.