What Is Visual Basic for Applications?
Microsoft Visual Basic for Applications (VBA) is a powerful
development technology for rapidly customizing rich-client desktop
packaged applications and integrating them with existing data and
systems. VBA offers a sophisticated set of programming tools based on
the Microsoft Visual Basic development system, the world's most
popular rapid application development system, which developers can use
to harness the power of packaged applications. VBA enables customers
to buy off-the-shelf software and customize it to meet their specific
business processes, rather than build solutions from scratch. This
helps them save time and money, reduce risks, leverage their
programming skills, and deliver precisely what users need.
Visual Basic for Applications provides a complete integrated
development environment (IDE) that features the same elements familiar
to developers using Microsoft Visual Basic, including a Project
Window, a Properties Window, and debugging tools. VBA also includes
support for Microsoft Forms, for creating custom dialog boxes, and
ActiveX Controls, for rapidly building user interfaces. Integrated
directly into a host application, VBA offers the advantages of fast,
in-process performance (up to 200 times faster than other stand-alone
development tools), tight integration with the host application (code
behind documents, cells, and so forth), and the ability to build
solutions without the use of additional tools.
Software programs that include VBA are called customizable
applications?applications that can be tailored to fit specific
business needs. This class of applications enables developers to
quickly build solutions that require less end-user training. For MIS
and business managers, customization means that solutions can be
developed quickly and deployed easily, with minimal maintenance. In an
industry familiar with two-year backlogs for new applications and high
end-user training costs, these solutions provide a tremendous business
benefit in terms of return on investment (ROI) and timeliness.
--------------------------------------------------------------------------------
Benefits of Visual Basic for Applications Licensing
The increasing number of VBA-enabled applications provides
opportunities for greater application customization and integration by
developers, allowing them to leverage their investments in training in
and knowledge of Visual Basic. Ultimately, these developer benefits
extend to the organizations and users who select VBA-enabled
applications over "build from scratch" solutions. Additional benefits
are outlined here:
Benefits to ISVs
Integrated, award-winning technology.
Licensing Visual Basic for Applications (VBA) enables ISVs to
concentrate on their core competency, rather than on language
development. It enables them to offer customers an award-winning
development environment, and means that ISVs don't have to build
proprietary technologies with differing tools and languages.
Competitive advantage.
Visual Basic for Applications delivers a competitive advantage for
ISVs seeking to provide full customization and integration
capabilities to customers. With VBA-enabled products, ISVs can build
broad capabilities into their core product while providing a
technology for customers to tailor the application and add features
and functionality specific to their requirements.
Simplified and extended applications.
VBA provides ISVs with a way to build VBA-based wizards directly into
their products to walk users through simple or complex operations.
After products ship, VBA enables ISVs to provide Web-based updates to
the core application, delivering new features and functionality
between product cycles.
Macro Recording.
With VBA and Macro Recording, ISVs can provide a simple way for end
users to automate repetitive tasks while providing developers with an
easy way of learning the application programming model.
An enormous developer community.
By licensing Visual Basic for Applications, ISVs can take advantage of
the 3.2 million developers already familiar with the Visual Basic
programming technology who can use an ISV's packaged applications as
development platforms. ISVs can also take advantage of the large
infrastructure already in place for Visual Basic:
Training facilities
Support centers
Books and magazines
Seminars
Events
Trade shows
Thousands of ActiveX Controls
Web sites
ISVs investing in VBA can extend their applications and deliver the
tools for meeting customers' specific demands. VBA-enabled products
impact the bottom line by providing a built-in customization
technology, enabling customers to pursue a "buy and customize"
alternative to building applications from scratch.
Benefits to Developers
Each VBA-hosted application exposes its functionality through an
object model, expanding the ActiveX-based component set available for
developers to use as building blocks for custom solutions.
Developers can become more marketable because they can use their skill
set across many applications.
The ability to reuse code is an immediate advantage because the same
Visual Basic is used everywhere.
Visual Basic for Applications enables customization of applications to
provide solutions tailored to customers' needs.
With the increasing availability of VBA-enabled applications,
developers can now integrate these applications to share data and
information more easily and seamlessly.
Perhaps most dramatically, Visual Basic for Applications enables
developers to build solutions that previously were cost-prohibitive,
because functionality is now available through the integration of
different applications or from different vendors.
With VBA available across a broad range of applications, developers
can customize and integrate line-of-business applications while
leveraging their existing skill set.
Benefits to MIS Managers
Developer knowledge can be used across a broad range of applications.
MIS managers can choose to buy instead of build, while enabling
application customization to meet specific business requirements.
MIS managers can adapt to changing resource requirements by taking
advantage of the huge number of developers skilled in Visual Basic
(over 3.2 million worldwide).
The backlog of end-user application demands can be reduced through
code reuse, resulting in a faster response.
Developers can be moved across development projects easily.
Visual Basic for Applications can also play a large role in helping
MIS managers and their companies lower training costs by reducing the
number of development environments or languages in which their
developers need to be trained.
Benefits to End Users of Application-Based Solutions
Solutions perform faster, thanks to tight integration between VBA and
host applications.
Solutions look and work like the applications users already know, so
less training is required.
Solutions can be user-customized, with respect to print options or
query creation, for example.
There is greater participation in the solution design process?users
can create the output, reports, and documents that they want
automatically generated.
Overall, users will benefit the most from improved solution quality
and customized functionality, as the applications they use today
incorporate richer functionality and integration, and are tailored to
meet their needs.
--------------------------------------------------------------------------------
Visual Basic for Applications Version 6.3
With the release of VBA 6.3 in March 2001, Microsoft has built on the
power of VBA 6.0, and has included new features that extend the power,
flexibility, and security of the development environment. This has
opened the door for new ISVs to develop even more powerful solutions
using new features, such as multithreaded VBA-based projects,
developer productivity add-ins, and support for digital signatures.
And with new integration technologies built by Microsoft, ISVs can
integrate VBA into their applications more quickly and easily than
ever.
Visual Basic for Applications 6.3 is a core component of Microsoft
Office XP (it's now in the Microsoft Outlook messaging and
collaboration client and the FrontPage Web site creation and
management tool, as well as Microsoft Access, Microsoft Excel,
Microsoft Word, and the Microsoft PowerPoint presentation graphics
program). Through the VBA licensing program, Microsoft is making the
same version of Visual Basic for Applications in Microsoft Office
broadly available for use in non-Microsoft applications, providing the
same ease of use and power of Visual Basic to a broad range of new
applications.
--------------------------------------------------------------------------------
How Does Visual Basic for Applications Fit with Other Microsoft Tools?
Microsoft offers a number of development tools aimed at specific
developer skills and needs. These include the Microsoft Visual C#,
Microsoft Visual C++, Microsoft Visual J++, and Microsoft Visual
FoxPro development systems; Microsoft Office Developer; and the Visual
Basic family: Visual Basic .NET, Visual Basic for Applications, and
Visual Basic Scripting Edition (VBScript). Tools such as Visual C#,
Visual C++, Visual J++, Visual FoxPro, and the Visual Basic
programming system support developers who build their solutions from
scratch to meet highly specific market needs. Microsoft Office
Developer and Visual Basic for Applications support those developers
who choose to buy and customize packaged applications rather than
build from scratch. Buying and customizing off-the-shelf software
reduces the cost and time of solution development when compared with
building from scratch. The Visual Basic family is designed to offer
powerful programming capabilities based on an easy-to-learn and
easy-to-use programming language.
Each member of the Visual Basic family also has specific uses.
VBScript is designed to offer lightweight scripting capabilities for
low-memory environments, such as Web browsers, and is most commonly
used in creating HTML Web pages. Visual Basic is the world's most
popular rapid-application development tool for creating stand-alone
software components, including executable programs, ActiveX Controls,
and COM components. Finally, Visual Basic for Applications takes the
same power available through the Visual Basic programming system and
applies it to highly functional applications, enabling infinite levels
of automation, customization, and integration.
Access may stop responding when you preview a report
Article ID : 824181
Last Review : July 29, 2004
Revision : 1.0
This article applies only to a Microsoft Access project (.adp).
Moderate: Requires basic macro, coding, and interoperability skills.
On this page
SYMPTOMS
CAUSE
WORKAROUND
REFERENCES
SYMPTOMS
If you try to preview a report that is grouped on one or more fields
that have many unique values in a Microsoft Access database project,
Access may stop responding, and the preview window may display the
status as Formatting Page.
Note You may still be able to print the problem report successfully.
CAUSE
This problem occurs when the report is based on a very large recordset
and the report is grouped on the fields in the recordset that contain
many unique values (in the thousands).
WORKAROUND
To work around this problem, do not preview the report directly in
Access if the report is based on a large recordset. Instead, you can
use a smaller recordset when you design and preview the report, and
then you can switch to the full recordset when you are ready to print
the report.
REFERENCES
For more information about how to group and sort in a report, click
Microsoft Office Access Help on the Help menu, type Change sorting and
grouping levels in the Search for box in the Assistance pane, and then
click Start searching to view the topic.
--------------------------------------------------------------------------------
How to automate the process of selecting the printer for a report in
Microsoft Access
Article ID : 319317
Last Review : February 22, 2005
Revision : 6.0
This article was previously published under Q319317
Novice: Requires knowledge of the user interface on single-user computers.
This article applies only to a Microsoft Access database (.mdb).
On this page
SUMMARY
MORE INFORMATION
REFERENCES
SUMMARY
If you want to print a report to a particular printer, you can
manually select the printer and all of the print options, or you can
automate the process so that with a click of a button, you can switch
printers and then print your report with the options that you
predefine. This article explains how to automate the process of
printer selection.
MORE INFORMATION
This procedure uses two examples: printing to a laser printer and
printing to a dot-matrix printer. You can substitute the particular
printers that you want to use. To automate the process of printer
selection for a particular report, follow these steps: 1. Create the
following three reports:
? rptLaserPrinter
? rptDotMatrix
? rptMyReport
NOTE: rptMyReport represents the actual report that you want to print.
2. To set the printer options, follow these steps: a. Open
rptLaserPrinter in Design view.
b. On the File menu, click Print.
c. In the Name box, click the laser printer that you want to use.
d. Click Properties, set any print options that you want, such as the
orientation and paper size, and then click OK.
e. Repeat steps a through d for rptDotMatrix. Click the dot-matrix
printer in step c.
3. In the Database window, click Modules, click New, and then type the
following function:
Function ChangePrinter(rptToChange As String, rptPrinter As String)
Dim rpt1 As Report, rpt2 As Report
DoCmd.OpenReport rptToChange, acViewDesign
DoCmd.OpenReport rptPrinter, acViewDesign
Set rpt1 = Reports(rptToChange)
Set rpt2 = Reports(rptPrinter)
rpt1.PrtDevNames = rpt2.PrtDevNames
DoCmd.Close acReport, rptPrinter, acSaveNo
DoCmd.OpenReport rptToChange, acViewPreview
End Function
NOTE: The ChangePrinter function copies the PrtDevNames property from
one report to another. You can then copy the print options that you
set for the rptLaserPrinter and rptDotMatrix reports to a specific
report that you want to print.
NOTE: The "acSaveNo" property is used in the "DoCmd.Close acReport,
rptPrinter, acSaveNo" line of the code that is shown earlier in this
section. If you do not use this option and you save the PrtDevName of
a nondefault printer to the report design, the report will not be able
to find the printer when it runs the next time. You will receive the
following error message:
This document was previously formatted for the printer <PrinterName>
on <Port>; but that printer isn't available. Do you want to use the
default printer <DefaultPrinterName> on <Port>?
4. Save the module as Module1, and then quit the Visual Basic Editor.
5. Create the following form: Form: frmForm1
------------------------------
RecordSource: Unbound
Control Type: Command Button
Name: cmdLaser
Caption: Laser
Control Type: Command Button
Name: cmdDotMatrix
Caption: Dot Matrix
6. On the View menu, click Code.
7. In the Visual Basic Editor, type the following procedures:Private
Sub cmdLaser_Click ()
Call ChangePrinter("rptMyReport", "rptLaserPrinter")
DoCmd.PrintOut
End Sub
Private Sub cmdDotMatrix_Click ()
Call ChangePrinter("rptMyReport", "rptDotMatrix")
DoCmd.PrintOut
End Sub
8. Quit the Visual Basic Editor, and then change the On Click property
of both command buttons to [Event Procedure]. To do so, follow these
steps: a. In Design view, click the command button, and then click
Properties on the View menu.
b. Click the Event tab, click the On Click property, click the down
arrow, and then click [Event Procedure].
9. To print rptMyReport to a specific printer, open frmForm1 in Form
view, and then click the appropriate button.
BUG: A control on a form or on a report that refers to a control on a
subform or on a subreport is blank in Access 2003
Article ID : 883867
Last Review : August 20, 2004
Revision : 1.0
This article applies to a Microsoft Access database (.mdb) and a
Microsoft Access project (.adp).
Moderate: Requires basic macro, coding, and interoperability skills.
On this page
SYMPTOMS
RESOLUTION
WORKAROUND
STATUS
MORE INFORMATION
REFERENCES
SYMPTOMS
When you open a form that contains a subform, you may notice that the
control on the form that refers to the control on the subform is
blank. When you open a report that contains a subreport, you may
notice that the control on the report that refers to the control on
the subreport is blank.
You notice this behavior when the following conditions are true:? The
expression in the ControlSource property for the control on the form
or on the report does not provide a full reference to the control on
the subform or on the subreport, respectively.
For example, to display a value that is calculated in the
OrderSubtotal control on the "Orders" subform, the following
expression is entered as the ControlSource property for the Subtotal
control on the "Orders" main form: =[Orders Subform]!OrderSubtotal
? Sandbox mode is turned on for Microsoft Office Access 2003 applications.
RESOLUTION
To resolve this problem, you must install Microsoft Office 2003
Service Pack 1 on your computer.
The following file is available for download from the Microsoft Download Center:
Office 2003 Service Pack 1
WORKAROUND
To work around this problem, you must modify the ControlSource
property for the control on the form or on the report. You do this to
provide a full reference to the control on the subform or on the
subreport, respectively.
To refer to a control on the subform, you must include the .Form
identifier in the expression that is entered as the ControlSource
property for the corresponding control on the main form.
For example, to display a value that is calculated in the
OrderSubtotal control on the "Orders" subform, you must enter the
following expression as the ControlSource property for the
corresponding control on the "Orders" main form:=[Orders
Subform].Form!OrderSubtotal
Similarly, to refer to a control on the subreport, you must include
the .Report identifier in the expression that is entered as the
ControlSource property for the corresponding control on the main
report.
For example, to display a value that is calculated in the QuarterTotal
control on the "Sales by Year" subreport, you must enter the following
expression as the ControlSource property for the corresponding control
on the "Sales by Year" main report: =[Sales by Year
Subreport].Report!QuarterTotal
STATUS
Microsoft has confirmed that this is a bug in the Microsoft products
that are listed in the "Applies to" section.
MORE INFORMATION
Steps to reproduce the problem
Caution If you follow the steps in this example, you modify the sample
database Northwind.mdb. You may want to back up the Northwind.mdb file
and follow these steps on a copy of the database. 1. Turn on Sandbox
mode for Access 2003 applications. To do this, follow these steps:a.
Start Access 2003.
b. On the Tools menu, point to Macro, and then click Security.
c. In the Security dialog box, click Medium on the Security Level
tab, and then click OK.
d. Close Access 2003.
Note If the macro Security menu item is missing, you must add the menu
item by customizing the toolbar.
For additional information, click the following article number to view
the article in the Microsoft Knowledge Base:
833219 Menu items are missing after you upgrade from an earlier
version of Microsoft Access to Microsoft Office Access 2003
2. Start Access 2003.
3. Open the Northwind.mdb sample database.
4. In the Database window, click Forms under the Objects section.
5. In the right pane, right-click Orders, and then click Design View.
The Orders form opens in Design view.
6. On the Orders form, locate, and then select the text box that is
named Subtotal.
7. On the View menu, click Properties.
8. On the Data tab, locate the Control Source property.
Notice that the Control Source property originally contains the
following expression: =[Orders Subform].Form!OrderSubtotal
On the Data tab, modify the expression in the Control Source property
to the following:=[Orders Subform]!OrderSubtotal
9. Save the form.
10. On the View menu, click Form View.
The Orders form opens in Form view.
Notice that the value in the Subtotal box is blank.
REFERENCES
For more information about Microsoft Jet Expression Service Sandbox
mode, click Microsoft Office Access Help on the Help menu, type about
Microsoft Jet Expression Service Sandbox mode in the Search for box in
the Assistance pane, and then click Start searching to view the topic.
For more information about referring to an object or to its properties
in expressions, click Microsoft Office Access Help on the Help menu,
type refer to objects in expressions in the Search for box in the
Assistance pane, and then click Start searching to view the topic. |