ACC2000: Using Lightweight Objects in AccessID: Q208196
|
This article describes the concept of lightweight objects and provides a technique to create a lightweight switchboard form that uses the Hyperlink properties of form controls to open other objects in the database.
Lightweight forms and reports, which are objects that do not contain a class module, were first introduced in Microsoft Access 97. One advantage of lightweight objects is that they are smaller and typically load and are displayed faster than objects with class modules. Also, because they require no storage space for a class module, they can decrease the size of your database. Possible disadvantages of using lightweight objects is that they do not appear in the Object Browser, and you cannot use the New keyword to create a new instance of the object.
When you create a new form or report, it is a lightweight object by
default. Access creates a class module for the object only if you do any of the following:
RunReport Action Arguments
-------------------------------
OpenReport
Report Name: Sales by Category
View: Print Preview
and then set the OnClick property of the command button to the following:
RunReport Action Arguments
-------------------------------
OpenReport
Report Name: Sales by Category
View: Print Preview
RunCode
Function Name: MyFunction()
Function ShowReport(txtReport As String)
DoCmd.OpenReport txtReport, acViewPreview
End Function
Form: frmMyform
-------------------------
Caption: fromMyform
ControlSource: <none>
Command button
-----------------------------------------
Name: Button0
Caption: My Button
OnClick: =ShowReport("Sales by Category")
Form: MySwitchboard
--------------------------------------
Caption: Main Menu
Command button
-----------------------------------
Name: OpenEmp
Caption: Employees Form
HyperlinkSubAddress: Form Employees
Label
-----------------------------------
Name: OpenCat
Caption: Catalog Report
HyperlinkSubAddress: Report Catalog
Image
-------------------------------
Name: OpenSales
Picture: C:\Windows\Circles.bmp
PictureType: Embedded
SizeMode: Clip
PictureAlignment: Center
PictureTiling: No
HyperlinkSubAddress: Query Category Sales for 1995
NOTE: If you do not have the file C:\Windows\Circles.bmp, you can substitute another bitmap or graphic file on your computer in the Picture property of the image control.For more information about the HasModule property, click Microsoft Access Help on the
Help menu, type "HasModule property" in the Office Assistant or the Answer Wizard,
and then click Search to view the topics returned.
For more information about class modules, click Microsoft Access Help on the
Help menu, type "class modules" in the Office Assistant or the Answer Wizard,
and then click Search to view the topics returned.
For more information about the HyperlinkSubAddress property, click Microsoft Access Help on the
Help menu, type "HyperlinkSubAddress property" in the Office Assistant or the Answer Wizard,
and then click Search to view the topics returned.
Additional query words: class lightweight bloat menu switchboard
Keywords : kbdta FmsProp FmsHowto
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: May 13, 1999