Some Special Query Functions & Expressions In Ms Access & Their Applications

There are some built in MS Access query functions to help you set more criteria. These functions apply to different field types. There are some for Date field, Text field, Number fields, etc. Some of these functions include the Between, Year, DatePart, DateSerial, DateAdd, etc. Most times they are combined with AND, OR, etc.
special ms access query built in functions and their practical application

There are many of them but in this part 3 of this MS Access tutorial chapter (chapter 4), I will now list about 16 of these expressions below with the fields they can be applied to, their expression and then their descriptions.


This is the part 3 of chapter 4 of the MS Access tutorials. You are advised to study part 1 of chapter 4: INTRODUCTION TO QUERIES IN MICROSOFT ACCESS 2013 AND 2016 or study part 2 hereAlso see the full tutorial course content of this Microsoft Access Tutorial Series.


The table or database from which we will draw our reference is shown below.
Query expression reference table

EXPRESSIONS THAT CALCULATE DATE AND ALSO USE THE RESULT AS CRITERIA

1. FIELD: PREDICTED REG DATE
EXPRESSION: Between Date() And DateAdd("m",2,Date())
DESCRIPTION: This expression displays records of Student’s whose Registration date fell between today’s date and two months from today’s date.

2. FIELD: REG DATE
EXPRESSION: <Date()-20
DESCRIPTION:
This expression displays the records of students whose registration dates are less than 20 days old.

3. FIELD: REG DATE
EXPRESSION: Year([REG DATE])=2016
DESCRIPTION:
This expression displays the records of students that registered in the year 2016.

4. FIELD: REG DATE
EXPRESSION: DatePart("q",[REG DATE])=3
DESCRIPTION:
This expression displays the records of students that registered in the third quarter of the calendar.

5. FIELD: REG DATE
EXPRESSION: DateSerial(Year([REG DATE]),Month([REG DATE])+1,1)-1
DESCRIPTION:
This expression displays the records of students that registered on the last day of the month.


6. FIELD: REG DATE
EXPRESSION: Year([REG DATE])=Year(Now()) And Month([REG DATE])=Month(Now())
DESCRIPTION: This expression displays the records of students that registered in the current year and month.

EXPRESSIONS THAT USE TEXT AS CRITERIA

1. FIELD: COUNTRY
EXPRESSION: "India"
DESCRIPTION: This expression displays the records of students that came from India.

2. FIELD: COUNTRY
EXPRESSION: "India" Or "USA"
DESCRIPTION: This expression displays the records of students that came from India or USA.

3. FIELD: REG DATE
EXPRESSION: Between #1/1/2016#
DESCRIPTION: This expression displays the records of students that registered on 1-Jan-2016. Note how the dates were enclosed in a pair of hash (#) sign.

4. FIELD: REG DATE
EXPRESSION: Between #1/1/2016# And #12/1/2016#
DESCRIPTION: This expression displays the records of students that registered not earlier than 1-Jan-2016 and not later than 1-Dec-2016.

5. FIELD: COUNTRY
EXPRESSION: In ("USA","India")
DESCRIPTION: This expression displays the records of students that came from USA or India.

6. FIELD: COUNTRY
EXPRESSION: Not "USA"
DESCRIPTION: This expression displays the records of students that came from other countries apart from USA.

7. FIELD: FIRST NAME
EXPRESSION: Like "N*"
DESCRIPTION: This expression displays the records of students whose first name begins with letter “N”, regardless of other letters or characters after it.

8. FIELD: FIRST NAME
EXPRESSION: >"J"
DESCRIPTION: This expression displays the records of students whose first name starts with letter “K” to “Z”.

9. FIELD: COUNTRY
EXPRESSION: Right([COUNTRY],5)
DESCRIPTION: This expression displays the records of students that the number of letters of their country is less than or equal to 5.

10. FIELD: FIRST NAME
EXPRESSION: Len([FIRST NAME])>=Val(6)
DESCRIPTION: This expression displays the records of students that the number of letters of their first name is greater than or equal to 6.

NOTE:

There other built in functions and expressions for querying a database, but the ones shown above are some of the common functions and expressions.
Also note how the field names are enclosed in a pair of square brackets.

This is the end of this part 3 of chapter 4. 

Recommended MS Access Textbook


ms access textbook kindle format


Click Here to know more about the book.

In the next two parts (parts 4 and 5), I will illustrate now show the practical or business applications of these query functions to students’ result system and workers’ payroll system respectively. 

Inform your friends about this post by clicking the share button below. Comment below if you are hooked up along the installation process.

Also click Here to subscribe for free so that you will get our latest game updates in your email.

No comments:

Post a Comment

WHAT'S ON YOUR MIND?
WE LOVE TO HEAR FROM YOU!