Frank said:
Hello,
I copied 1 VBA of a text control of a form to another text control of
another form because I expect it to work the same way. but it can not
work.
I see in the VBA code of the text control that work there is the
following at top while in the other no.
Option Compare Database
Option Explicit
May I know what is the meaning of this 2 lines, I just want to know
what makes it not work.
Thanks in advance
Most likely it is the second one causing your error, but it is recommended
that you always use it.
From Access help:
Option Explicit
If you don't use the Option Explicit statement, all undeclared variables are
of Variant type unless the default type is otherwise specified with a
Deftype statement. Note Use Option Explicit to avoid incorrectly typing
the name of an existing variable or to avoid confusion in code where the
scope of the variable is not clear.
Option Compare
The Option Compare statement specifies the string comparison method (Binary,
Text, or Database) for a module. If a module doesn't include an Option
Compare statement, the default text comparison method is Binary.
Option Compare Binary results in string comparisons based on a sort order
derived from the internal binary representations of the characters. In
Microsoft Windows, sort order is determined by the code page. A typical
binary sort order is shown in the following example:
A < B < E < Z < a < b < e < z < À < Ê < Ø < à < ê < ø
Option Compare Text results in string comparisons based on a
case-insensitive text sort order determined by your system's locale. When
the same characters are sorted using Option Compare Text, the following text
sort order is produced:
(A=a) < ( À=à) < (B=b) < (E=e) < (Ê=ê) < (Z=z) < (Ø=ø)
Option Compare Database can only be used within Microsoft Access. This
results in string comparisons based on the sort order determined by the
locale ID of the database where the string comparisons occur.