INF: Access Basic and Macros Questions & Answers
  
PSS ID Number: Q104389
Article last modified on 02-07-1995
 
1.00 1.10
 
WINDOWS
 

---------------------------------------------------------------------
The information in this article applies to:
 
 - Microsoft Access versions 1.0 and 1.1
---------------------------------------------------------------------
 
======================================================================
  Microsoft Product Support Services Application Note (Text File)
        WX0636: ACCESS BASIC AND MACROS QUESTIONS & ANSWERS
======================================================================
                                                   Revision Date: 9/93
                                                      No Disk Included
 
The following information applies to Microsoft Access, versions 1.0,
and 1.1.
 
-----------------------------------------------------------------------
| INFORMATION PROVIDED IN THIS DOCUMENT AND ANY SOFTWARE THAT MAY     |
| ACCOMPANY THIS DOCUMENT (collectively referred to as an Application |
| Note) IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER      |
| EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED      |
| WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR       |
| PURPOSE. The user assumes the entire risk as to the accuracy and    |
| the use of this Application Note. This Application Note may be      |
| copied and distributed subject to the following conditions:  1) All |
| text must be copied without modification and all pages must be      |
| included;  2) If software is included, all files on the disk(s)     |
| must be copied without modification (the MS-DOS  utility         |
| diskcopy is appropriate for this purpose);  3) All components of    |
| this Application Note must be distributed together;  and  4) This   |
| Application Note may not be distributed for profit.                 |
|                                                                     |
| Copyright (C) 1992-1993 Microsoft Corporation.  All Rights Reserved |
| Microsoft, Microsoft Access, and MS-DOS are registered trademarks   |
| and Windows is a trademark of Microsoft Corporation.                |
-----------------------------------------------------------------------
 
1.  Q. How can I run macros from Access Basic?
 
    A. The following are three suggested ways to run macros from
       Access Basic:
 
       - Create the macro using the macro editor and then call it from
         your Access Basic procedure. For example, if you create a macro
         called Macro1, you can call the macro from a procedure with the
         following command:
 
            DoCmd RunMacro "macro1"
 
       - Call the macro from the Immediate window using the same syntax
         as you would in Access Basic. Again, the syntax is as follows:
 
            DoCmd RunMacro "macro1"
 
       - Use DoCmd to run a macro action, rather than creating a macro
         specifically for that action. The basic format of DoCmd is as
         follows:
 
            DoCmd <Action> <Argument1>, <Argument2>
 
         For more information on DoCmd, RunMacro, and macro actions,
         please refer to the "User's Guide" and "An Introduction to
         Programming;" or, search Help on the keywords DOCMD and
         Expressions in Macros and Actions.
 
2.  Q. When should I use the Variant data type?
 
    A. Use the Variant data type if you are unsure what type of data
       you are working with. When you use the Variant data type,
       Microsoft Access evaluates the data and then handles it
       appropriately. Using variants avoids the step of assigning data
       types to variables and manually converting data types in your
       programs. Further, when you store table data in variables,
       using variants eliminates complications with NULL data values.
 
3.  Q. How do I comment out a macro action?
 
    A. With the macro in Design view, choose Conditions from the View
       menu. This adds the Condition column to the macro design. Type
       "false" (without the quotation marks) on the condition line for
       the macro action you want to comment out.
 
4.  Q. How do I bypass the AutoExec startup macro when I open a
       database?
 
    A. Hold down the SHIFT key when you open the database to prevent
       Microsoft Access from executing that database's AutoExec macro.
 
5.  Q. How do I include a variable or form reference in the WHERE
       clause of my SQL statement?
 
    A. The syntax for including a variable or form reference in the
       WHERE clause of an SQL statement depends on the data type of
       the variable. Numeric variables do not require delimiters,
       string variables should be enclosed in single quotation marks,
       and date variables require the number sign (#). You must
       concatenate the variable and use the appropriate delimiter, if
       required, as shown in the examples below:
 
       For a numeric variable, use the following syntax:
 
          myq.sql = "select * from orders where [employee id]=" &
          mynum & ";"
 
       For a string variable, use the following syntax:
 
          myq.sql = "select * from orders where [customer id]='" &
          mytext & "';"
 
       For a date variable, use the following syntax:
 
          myq.sql = "select * from orders where [order date]=#" &
          mydate & "#;"
 
       For additional information on concatenating variables, please
       obtain Technical Note #96576. You can order this technical note
       by selecting the FastTips Technical Library option from the
       FastTips Main Menu.
 
Additional reference words: 1.00 1.10
KBCategory: kbusage kbfasttip kbappnote
KBSubcategory: FstQa
=============================================================================
Copyright Microsoft Corporation 1995.
