1. Open the StockTracking-04.accdb database file from your student data files and save it as [your
initials] Access Project 4.
2. If prompted, enable content in the database.
3. Create an update action query to modify data in the Stocks table. Someone has entered the wrong
sector name on some of the stocks.
Page 1 of 8
4.
5.
6.
7.
Page 2 of 8
h. Right-click the relationship line and select Join Properties to open the Join Properties dialog box
(Figure 1).
i.
j.
Page 3 of 8
d. Set the following properties for the combo box: Enter comboSector in the Name property,
1.5 in the Width property, .5 in the Top property, 2.5 in the Left property, and Text
Black in the Fore Color property. On the Data tab, enter Select Distinct Sector
from Stocks; in the Row Source property to assign the data source to the combo box.
Adding Distinct into the SQL query eliminates duplicates.
e. Set the following properties for the label associated with the sector combo box: Enter 2 in
the Width property, 1 in the Height
property, .5 in the Top property, .4
in the Left property, and Text Black
in the Fore Color property. Select Center
in the Text Align property box, and type
Click the arrow to select
the desired sector, or
leave blank to display
stocks in all sectors. in the
Caption property. To have the contents
wrap, as shown in Figure 3, click inside
the label control and press Shift+Enter
before or, and again after or.
f. Add another combo box control to the
Figure 3 - Design view of GetSectorIndustryParameters form
form to capture the industry parameter.
g. Set the following properties for the combo box: Enter comboIndustry in the Name property,
3 in the Width property, 1.8 in the Top property, 2.5 in the Left property, and Text
Black in the Fore Color property. On the
Data tab, select No in the Enabled property
and open the Zoom window in the Row
Source property. Enter the SQL statement
in Figure 4 in the Zoom window and click
Figure 4 SQL statement for the comboIndustry control
OK. This query displays only the industries
for the selected sector.
h. Set the following properties for the label associated with the industry combo box: Enter 2 in
the Width property, 1 in the Height property, 1.8 in the Top property, and .4 in the Left
property. Select Center in the Text Align property box, and type Once a sector is
selected, if desired, you can click the arrow to limit the
results to an industry within the chosen sector. in the Caption property.
To have the contents wrap, as shown in Figure 3, click inside the label control and press
Shift+Enter before to an.
i. Add a button control to the form and set the following properties for the button: Enter OK in
the Caption property, 3 in the Top property, 1 in the Left property, and cmdOK in the Name
property.
j. Add a second button control to the form and set the following properties for the button: Enter
Cancel in the Caption property, 3 in the Top property, 3 in the Left property, and
cmdCancel in the Name property.
Page 4 of 8
10.
11.
12.
13.
Page 5 of 8
Page 6 of 8
16.
17.
18.
19.
c. Click the Subform/Subreport button and click in the Detail section of the form (near the left
edge and below the label). Choose to add the VolumeSubform onto the main form and accept
the suggested name for the subform. Because the main form is not bound to a record source,
the wizard did not ask you how to link the two forms.
Set the link fields on the subform.
a. If needed, open the Property Sheet and select the Data tab.
b. Click to select the subform. Verify that VolumeSubform appears in the Selection type drop-down
list.
c. Enter [comboVolSector] in the Link Master Fields property. This is the name of the combo
box on the main form.
d. Enter [Sector] in the Link Child Fields property. Although the Sector field does not display on
the subform, this field is included in the data source of the subform.
e. Save the main form.
f. Switch to Form view to
preview the form
(Figure 8).
g. Select Industrial Goods
in the combo box. The
subform updates to
display the two stocks
in this sector.
Customize the subform to
adjust the form size,
remove the border and
Navigation bar, and edit
the label.
a. Switch to Design view.
b. Select the subform and Figure 8 - Form view of main form with added subform
change the Width
property to 9.3, the Height property to 2.6, the Top property to 1.4, the Left property
to .25, and select Transparent in the Border Style property.
c. Inside the subform, click the Select All box to select the subform and then select No in the
Navigation Buttons property box.
d. Select the label control of the subform and make the following changes to these properties:
Enter Stocks in this Sector in the Caption property, 1.4 in the Width property,
1.1 in the Top property, and .5 in the Left property.
e. Save the form.
Add a calculated control onto the subform and enter an aggregate function.
a. Add a text box control to the Form Footer section of the subform.
b. Enter =Avg([AvgOfVolume]) into the Control Source property and SFAvgVol in the Name
property.
c. Delete the label that was added with the text box.
d. Save the form.
Add a text box to the main form to reference a control from the subform.
Page 7 of 8
a. Add a text box control on the main form, to the right of the combo box and make the following
changes to these properties: Enter =[VolumeSubform].[Form]![SFAvgVol] into the
Control Source property, select Standard in the Format property, enter 1 in the Width
property, .3 in the Top property, and 7 in the Left property. Select No in the Tab Stop
property.
b. Select the label control of that text box and make the following changes to these properties:
Enter Average Volume in the Caption property 1.2 in the Width property, .3 in the Top
property, and 5.8 in the Left property.
c. Save the form and change to Form view. Note that the average volume text box displays #Error.
This displays since the subform does not yet have any data, and as a result, the SFAvgVol text
box does not have a value.
d. Change to Design view to fix the error.
e. Edit the Control Source property of the text box to read:
=IIF(IsNull([ComboVolSector]),Null,
[VolumeSubform].[Form]![SFAvgVol] This expression uses the Access IIF
(Immediate If) function which is similar to the IF function in Excel. Based on whether the combo
box is empty (null) or not, the IIF function chooses the correct value to display.
f. Save the form.
20. Test the form.
a. Switch to Form view. Note that the average volume text box no longer displays #Error.
b. Select Industrial Goods in the combo box. The subform updates to display the two stocks in this
sector and the average volume text box updates to read 3,352,588.43.
c. Select Services in the combo box. The average volume textbox and subform update. Note that
the subform scroll bars display when needed (Figure 9).
Page 8 of 8