Using ActiveX controls, you can add extra functionality to your application forms and reports. These controls are available from both Microsoft and other companies (note that not all ActiveX controls will work correctly with Access). You should consult any third-party documentation regarding details for using specific controls. In this section, you will see two examples of popular controls. For an example that demonstrates how to work with the TreeView control, see Chapter, “Using Form Controls and Events.”
ActiveX on 64-bit computers
If you are using the 64-bit version of Microsoft Office, you will not be able to use these 32-bit controls; 64-bit versions of these controls are not available. Both of these points might change in later Service Packs.
Adding a Slider Control
With the Slider control, a user can move a slider to change a value. To add the control, start with a blank form. In Form design, on the Design tab, click ActiveX Controls, as shown in Figure.
Click ActiveX Controls on the Design tab to add an ActiveX control to a form.
In the Insert ActiveX Control window, click the Slider control, as shown in Figure.
Adding an ActiveX control to the form.
Figure shows the slider control in the sample form frmSliderControl.
A form with a Slider control.
To detect where a user has positioned the slider, you need to capture an event from the slider object. If you look in the references, you might see an entry for the Windows Common Controls. If it is present, then select the reference; if you do not see the reference, you will need to browse to locate the file MSCOMCTL.OCX, as shown in Figure.
Adding the OCX file to create the entry in the references when you do not already have the reference on a 64-bit operating system.
Figure shows that for a 64-bit system, the file resides in the SysWOW64 directory.
Windows Common Controls 6.0 reference.
After adding the reference, you can write the following code on the form to respond to the Scroll event for the slider control:
The UpDown or Spin Control
The UpDown or Spin control consists of two buttons that are used to increase or decrease a number. This control is normally used with a text box to display the value. In Form design, on the Design tab, click ActiveX Controls to display the Insert ActiveX Control window, and then choose the control, as shown in Figure.
Inserting the UpDown ActiveX control on the form.
Figure shows the Spin control in the sample form frmUpDownButton.
A form demonstrating the Spin control; the spin control buttons are next to a text box that displays the value.
You want to trap events generated by the buttons, so you need to add a reference to the Windows Common Controls-2. If you do not have this reference (it should already be added when you place the control on the form), then you need to browse and locate the file mscomct2.ocx, as shown in Figure.
Adding the reference to mscomct2.ocx for the spin control.
On a 64-bit system, the file resides in the SysWOW64 directory as illustrated in Figure.
Windows Common Controls-2 reference for the spin control.
After adding the reference, you can write the following code on the form to respond to these UpDown events when a user clicks one of the spin buttons:
MS Access Related Tutorials
|Oracle 8i Tutorial||VBA For Excel Tutorial|
|Management Information systems Tutorial||Microsoft Excel Tutorial|
|Microsoft Word Tutorial||Advanced Excel Charts Tutorial|
|Advanced Excel Functions Tutorial||Excel Dashboards Tutorial|
|Excel Data Analysis Tutorial||Excel pivot tables Tutorial|
|Excel Power View Tutorial|
MS Access Related Interview Questions
|Oracle 8i Interview Questions||VBA For Excel Interview Questions|
|Management Information systems Interview Questions||Microsoft Excel Interview Questions|
|Microsoft Word Interview Questions||Microsoft FrontPage Interview Questions|
|Excel Data Analysis Interview Questions||Excel pivot tables Interview Questions|
|Excel Power View Interview Questions||Access Control List Interview Questions|
Ms Access Tutorial
Using The Vba Editor And Debugging Code
Understanding The Vba Language Structure
Understanding The Vba Language Features
Applying The Access Object Model
Understanding The Data Access Object Model
Using Forms And Events
Using Form Controls And Events
Creating Reports And Events
Adding Functionality With Classes
Using Classes And Events
Using Classes And Forms
Linking Access Tables
Integrating Microsoft Office
Using Sql Server
Upsizing Access To Sql Server
Using Sql Azure
Using Ado And Adox
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.