Do it now activity
description
Transcript of Do it now activity
KEYWORDS
Do it now activity
1. Understand how to create calculated fields on Forms2. Understand the purpose of automation of processes
LEARNINGOBJECTIVES
How will you create a simple query that returns all of the students details?
Once you have logged on open your database and create the query
SecurityPasswordData protection act
If statementIsNullMessage Box
1. Understand how to create calculated fields on Forms
2. Understand the purpose of automation of processes
Learning Objectives
1.Create calculated field to create a running total and generate a date based on a previous date
2.Generate age based on DOB and auto generate group based on age
By the end of the lesson you will be able to …
=Fix(DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")<Format([DOB],"mmdd")))
Generate age based on DOB field
Replace both [DOB] fields with the name of your date field that you want to generate the age from
This expression should be placed on your default value of the field you want the age to appear in
You will need to have a requery macro set up to run on lost focus of the last field you require the user to type in
=IIf([Age]>30 And [Age]<=60,"Group3“,"No Group")
Iif statement
This iif statement is used to generate the name of the group that the person will be assigned to based on their age. [Age] is the name of the field that holds the age that you will base the iif statement on – change this field name as necessary
This expression should be placed on the default value of the field that you want to store the group that the person is auto
assigned to.
You will need to have a requery macro assigned to the last field you want the user to type in for this to update and show
in the field
Group the person is assigned to if condition is met
Group the person is assigned to if condition is not
met
Condition checks if age is between two parameters
=IIf([Age]>30 And [Age]<=60,"Group3",IIf([Age]>20 And [Age]<=30,"Group2",IIf([Age]>=10 And [Age]<=20,"Group1","No Group")))
Nested iif statement
Nested version of the iif statement
which checks several conditions and assigns to a
choice of 3 groups based on these
conditions
If no conditions are met the user is assigned to No
Group
Calculated control – running total
Just add the two fields that
you want to add together
with a + symbol
between them
To access the expression
builder click on … next to
control in the data tab of the fields property
sheet
DMax("[Payment Date]","[TBL_Payments]","[Student ID]=‘” & [ID] & "'")
Dmax to find latest payment date based on the ID of the student selected on a form
This expression will also need to go into the calculated control of the field – click on … next to the control property of the field
where this data should be displayed
Field name
Table name
Student ID on the table
Student ID on the form
=DateAdd("m",1,DMax("[Payment Date]","[TBL_Payments]","[Student ID]=‘ " & [ID] & “ ‘ "))
Add 1 month to the latest payment date of the student
selected on the form
Adds 1 month to the latest payment date stored in the table
Expression name month Add 1
Update query to update the amount each student has
paidCreate a query based on TBL_Student – make it an update query and set it to update TBL_Student
Test the query by selecting a student on FRM_Payment and adding a payment – run the query it should update
the currently paid value in TBL_Student
Create a button on FRM_Payment and add an openQuery macro to run the update query when it is
clicked
Update this field to the value in the field called runningTotal on
FRM_Payment
Update this on the student with the same ID
as the student selected on FRM_Payment
Append query to add new payment to TBL_Payments
Create an append query that appends data to TBL_PaymentCreate the 4 fields shown
Test the query by creating a payment on FRM_Payment and running the query – it should add a payment to your TBL_Payment
Add a second openQuery macro to your button on FRM_Payment to run the query
KEYWORDS
LEARNINGOBJECTIVES
MB1(with help)
1.Create calculated field to create a running total and generate a date based on a previous date
1.Generate age based on DOB and auto generate group based on age
MB2(with pointers)
MB3(independently)
1. Understand how to create calculated fields on Forms2. Understand the purpose of automation of processes