Microsoft Access VBA Macro Programming

(Tina Sui) #1

Creating a Form for the Table


Create a form based on the Suppliers table by clicking Create in the Access menu and
clicking the Form Design icon in the Forms group of the ribbon. Right-click the form in
Design mode and select Properties. On the Property Sheet, select Form in the drop-down at
the top and set the Record Source property to tblSupplier.
Add on to the form two drop-down (combo) boxes and one text box. Go to the property sheet
for each control and set the Control Source property for the first drop-down to SupplierSize and
the second drop-down to SupplierName. Set the Control Source property for the text box to
SupplierRef.
Set the Row Source property for the SupplierSize drop-down to the SQL statement:


SELECT DISTINCT SupplierSize FROM tblSupplier;


Your form should now look like Figure 39-3.
You can now add some VBA code to your form to make it interactive. Right-click the
SupplierSize drop-down and select Build Event. Select Code Builder in the pop-up box and
you will be taken to the VBE window for the form. For the Combo0 control (assuming that


Chapter 39: Make Controls on Forms Interactive 351


Figure 39-2 Data for the supplier table
Free download pdf