ACC97: Macro to VBA Uses Unexpected Syntax with Form ReferencesLast reviewed: August 29, 1997Article ID: Q162074 |
The information in this article applies to:
SYMPTOMSAdvanced: Requires expert coding, interoperability, and multiuser skills. When you use the "Convert Macros to Visual Basic" command to convert a macro that contains a reference to a user-defined item on a form or report to a Visual Basic for Applications event procedure, the code syntax that is created from the conversion will use the "." (dot) operator instead of the "!" (exclamation point) operator for any implicit referencing in the procedure.
CAUSEThe "Convert Macros to Visual Basic" command does not differentiate between implicit and explicit referencing when a macro is converted to a Visual Basic for Applications procedure.
RESOLUTIONIn modules that are created from the "Convert macros to Visual Basic" command, both operators are acceptable.
MORE INFORMATIONIn Microsoft Access, the "!" operator and the "." operator are used as identifiers to indicate if a particular reference is implicit ("!") or explicit(".") Implicit referencing usually means that you are referring to a user-defined item. Explicit referencing usually means you are referring to an item defined by Microsoft Access. However, when you use the "Convert Macros to Visual Basic" command, the distinction is not made for implicit and explicit form referencing. For example, if the macro contains an entry in the condition column that reads as follows
Condition Action ------------------------------ [PrintLabelsFor]=1 SetValue Action Arguments -------------------------------------- Item: [SelectCountry].[Enabled] Expression: Noit will be converted to the following:
With CodeContextObject If (.PrintLabelsFor = 1) ThenNote the "." operator that precedes PrintLabelsFor. The "!" operator should be used instead of the "." operator.
Steps to Reproduce Behavior
With CodeContextObject ' Attached to the Customer Labels Dialog form. ' Attached to the PrintLabelsFor option group. If (!PrintLabelsFor = 1) Then ' If user selects All Countries, do not enable the SelectCountry ' combo box. !SelectCountry.Enabled = False End If If (!PrintLabelsFor = 2) Then ' If user selected Specific Country, enable the SelectCountry ' combo box. !SelectCountry.Enabled = True ' Go to the SelectCountry DoCmd.GoToControl "SelectCountry" End If End With REFERENCESFor more information about implicit and explicit form referencing, search the Help Index for "referencing, controls in expressions," and then "Use the ! and .(dot) operators in expressions" or ask the Microsoft Access 97 Office Assistant. Keywords : kbprg SynRef Version : 97 Platform : WINDOWS Hardware : x86 Issue type : kbprb |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |