However, if you intend to share your database with other people by locating it on a file server, you might want to avoid using VBA for security considerations. You should base your decision to use either macros or VBA code on two concerns: security and the functionality that you want. Security is an issue because VBA can be used to create code that either compromises the security of your data or can harm files on your computer.
When you use a database that was created by someone other than yourself, you should enable VBA code only if you know the database comes from a trustworthy source. When you create a database that will be used by other people, you should try to avoid including programming tools that require the user to specifically grant trusted status to the database. General techniques for avoiding the need for users to trust your database come later in this section.
To help ensure the security of your database, you should try to use macros when you can and use VBA programming only for operations that cannot be performed by using macro actions. Furthermore, you should try to use only macro actions that don't require granting trusted status to the database in order to run.
Limiting the use of macro actions in this manner lets users to be confident that the database has no programming that could harm the data or other files on their computers. Beginning in the Access release, Access contains many new macro actions that enable you to build more powerful macros than you can build by using earlier versions of Access.
For example, you can now create and use global temporary variables by using macro actions, and you can handle errors more gracefully by using new error-handling macro actions. In earlier versions of Access, these kinds of features are available only by using VBA. In addition, you can embed a macro directly into the event property of an object or control.
An embedded macro becomes a part of the object or control and stays with the object or control if it is moved or copied. Macros provide an easy way to handle many programming tasks, such as opening and closing forms and running reports.
You can quickly and easily tie together the database objects forms, reports, and so on that you have created because there is little syntax that you must remember. The arguments for each action are displayed in the Macro Builder. In addition to the increased security and ease of use that macros provide, you must use macros to perform the following tasks:.
Assign an action or set of actions to a key. This requires creating a macro group named AutoKeys. Carry out an action or a series of actions when a database first opens. This requires creating a macro named AutoExec. For more information about how to build macros, see the section Understand macros. Use built-in functions, or create your own functions Access includes many built-in functions, such as the IPmt function, which calculates an interest payment.
You can use these built-in functions to perform calculations without having to create complicated expressions. By using VBA code, you can also create your own functions either to perform calculations that exceed the capability of an expression or to replace complex expressions.
In addition, you can use the functions that you create in expressions to apply a common operation to more than one object.
Create or manipulate objects In most cases, you will find that it is easiest to create and modify an object in that object's Design view. In some situations, however, you might want to manipulate the definition of an object in code. By using VBA, you can manipulate all the objects in a database, in addition to the database itself.
Perform system-level actions You can carry out the RunApp action in a macro to run another program such as Microsoft Excel from within Access, but you can't use a macro to do much else outside of Access. Manipulate records one at a time You can use VBA to step through a set of records, one record at a time, and perform an operation on each record. In contrast, macros work with entire sets of records at one time.
If you are adding a command button to a form, the Command Button Wizard can help you get started with programming. The wizard helps you create a command button that performs a specific task. In an Access. Visual Basic is grayed out on my Excel - do I need to have Visual Basic installed to correct this issue? I posted this issue in the Outlook area, and they recommended I contact Excel for help.
Was this reply helpful? Yes No. Sorry this didn't help. Thanks for your feedback. This thread is locked. You can follow the question or vote as helpful, but you cannot reply to this thread.
When you open a file or try to use macros in Microsoft Office Click 2 Run C2R , you may experience one of the following symptoms. Windows Installer window continuously flashes. When you use Access wizards you get the following error:.
When you open presentations with VBA code you get the following error:. Macro language support for this application is disabled. Features requiring VBA are not available. Would you like to open this document read-only? Non-Microsoft registry cleaners and system maintenance applications deleted multiple registry key values that are used for VBA functionality in Microsoft Office applications.
Click your Microsoft Office program, and then click Change. To do this, follow these steps:. Microsoft Access requires Visual Basic for Applications. To enable the installation of Access and disable Visual Basic for Applications in all other Office programs, install a stand-alone version of Microsoft Access, and then install Office as a custom installation that has Visual Basic for Applications disabled.
The VBAOff registry subkey can be added manually to disable Visual Basic for Applications functionality for all users on a computer after Office is installed.
To add the VBAOff registry key, follow these steps:. Click Start , click Run , type regedit, and then click OK. Locate and then click to select one of the following registry keys, depending on the version of the product that you are using:.
Note You can also disable Visual Basic for Applications functionality for the current user only. Skip to main content.
0コメント