ACC97: No Error When AddFromFile Creates Duplicate ProcedureLast reviewed: July 18, 1997Article ID: Q171072 |
The information in this article applies to:
SYMPTOMSAdvanced: Requires expert coding, interoperability, and multiuser skills. The AddFromFile method does not generate an error when it adds a duplicate procedure to a module.
CAUSEWhen the AddFromFile method inserts a procedure into a module, Visual Basic for Applications tries to compile all code in the target module first, and then inserts the procedure if successful. If you use the AddFromFile method multiple times to insert the same procedure into the same target module, Visual Basic for Applications does not detect a compile error until the third attempt. On the first attempt, Visual Basic for Applications successfully compiles the code, and then inserts the procedure from the text file. On the second attempt, Visual Basic for Applications successfully compiles the code in the target module, which now includes one instance of the procedure from the text file; it then inserts a second copy of the procedure from the text file. On the third attempt, Visual Basic for Applications detects a compile error because there are two instances of the same procedure in the target module.
RESOLUTIONTo prevent the AddFromFile method from inserting a duplicate procedure, use the Find method of the Module object to determine if the procedure already exists in the module. To do so, follow these steps:
STATUSThis behavior is by design.
MORE INFORMATION
Steps to Reproduce Behavior
REFERENCESFor more information about using the AddFromFile method, search the Help Index for "AddFromFile method." For more information about using the Find method, search the Help Index for "Find method", and then "Find Method (Microsoft Access Reference)". |
Keywords : kbcode kbprg MdlProb PgmErr PgmHowTo
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |