0% found this document useful (0 votes)
2 views28 pages

Lecture 2

The document provides detailed instructions on how to set field properties in Microsoft Access, including field size, format, and validation rules. It explains various formatting options for text, numbers, currency, and dates, as well as how to implement input masks and captions for better data entry. Additionally, it covers the importance of validation rules to maintain data integrity and offers examples of specific validation criteria.

Uploaded by

fetleworkamsalu5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views28 pages

Lecture 2

The document provides detailed instructions on how to set field properties in Microsoft Access, including field size, format, and validation rules. It explains various formatting options for text, numbers, currency, and dates, as well as how to implement input masks and captions for better data entry. Additionally, it covers the importance of validation rules to maintain data integrity and offers examples of specific validation criteria.

Uploaded by

fetleworkamsalu5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

MHC Dilla Campus

OPERATE DATABASE
APPLICATION
Microsoft Office Access
Field Properties
 Properties for each field are set from the
bottom pane of the Design View window.
Field Size
 Is used to set the number of characters needed

in a text or number field.


 The default field size for the text type is 50

characters.
 If the records in the field will only have two or

three characters, you can change the size of


the field to save disk space or prevent
entry errors by limiting the number of
characters allowed. MHC Dilla Campus
Field Properties
 Likewise, if the field will require more than 50
characters, enter a number up to 255.
 The field size is set in exact characters for Text type

Format
 Conforms the data in the field to the same format

when it is entered into the datasheet.


 For text and memo fields, this property has two

parts that are separated by a semicolon.


 The first part of the property is used to apply to the
field and
 The second applies to empty fields.

MHC Dilla Campus


Text and memo
format
Text format
Format Data entry Display explanation
@@@-@@@@ 1234567 123- @ indicates a
4567 required
character or space
@@@-@@@& 123456 123-456 & indicates an
optional
character or space
< HELLO hello < converts
characters to
lowercase
> hello HELLO > converts
characters to
uppercase
@\! Hello Hello! \ adds characters
to the end
@;"No Data Entered" Hello MHC DillaHello
Campus
Field Properties

Number format
 Select one of the preset options from
the drop down menu or construct a
custom format using symbols explained
below:

MHC Dilla Campus


Number format
Format Data entry Display explanation
###,##0.00 123456.78 123,456 0 is a placeholder
.78 that displays a
digit or 0 if there is
none.
$###,##0.00 0 $0.00 # is a placeholder
that displays a
digit or nothing if
there is none.

###.00% .123 12.3% % multiplies the


number by 100
MHC Dilla Campus
and added a
Field Properties
Currency format
 This formatting consists of four parts
separated by semicolons:
 format for positive numbers;
 format for negative numbers;
 format for zero values;
 format for Null values.

MHC Dilla Campus


Currency Format
Format Explanation
$##0.00;($##0.00) Positive values will be
[Red];$0.00;"none" normal currency
format, negative
numbers will be red in
parentheses, zero is
entered for zero
values, and "none"
will be written for Null
values.
MHC Dilla Campus
Field Properties
Date format
 In the table below, the value "1/1/01" is
entered into the datasheet, and the
following values are displayed as a result
of the different assigned formats.

MHC Dilla Campus


Date Format
Format Display Explanation
dddd","mmmm d", Monday, January 1 dddd, mmmm, and
"yyyy , 2001 yyyy print the full day
name, month name,
and year
ddd","mmm ". " d" Mon, Jan. 1, '01 ddd, mmm, and yy
, '"yy print the first three
day letters, first three
month letters, and
last two year digits
"Today is " dddd Today is Monday
h:n:s: AM/PM 12:00:00 AM "n" is used for
MHC Dilla Campus
minutes to
Field Properties
 Yes/No fields are displayed as check
boxes by default on the datasheet.
 To change the formatting of these fields,
first click the Lookup tab and change the
Display Control to a text box. Go back to
the General tab choices to make
formatting changes.

MHC Dilla Campus


Field Properties
 The formatting is designated in three sections
separated by semicolons.
 The first section does not contain anything but the
semicolon must be included.
 The second section specifies formatting for Yes values and
 The third for No values.

Yes/No Format
Format Explanation
;"Yes"[green];"No"[red] Prints "Yes" in green or "No" in
red

MHC Dilla Campus


Field Properties
Default Value
 There may be cases where the value of a
field will usually be the same for all
records.
 In this case, a changeable default value
can be set to prevent typing the same
thing numerous times.
 Set the Default Value property.
MHC Dilla Campus
Field Validation Rules
 Validation rules in Microsoft Access are used to ensure
that the data entered into a field or a record meets
specific criteria.
 They help to maintain data integrity and accuracy by
preventing incorrect or invalid data from being
entered.
 Some common examples of validation rules include:
 1. Data type validation: Ensuring that the data
entered into a field matches the specified data type,
such as a numeric field only accepting numbers.
 2. Range validation: Specifying a range of
acceptable values for a field, such as specifying that a
number field should be between 1 and 10.
MHC Dilla Campus
Field Validation Rules
 3. Format validation: Defining a specific format
for a field, such as a date field should be entered
in the format "mm/dd/yyyy".
 4. Required field validation: Ensuring that a
field must have a value entered before saving a
record.
 5. Custom validation: Defining custom rules or
formulas to validate data, such as only allowing a
specific combination of field values to be entered.
 By setting up validation rules, users can ensure
that the data entered into their Access database
is accurate and consistent,
MHC Dilla reducing
Campus errors and
To do this ... Validation Rule for Fields Explanation

Accept letters (a - z) Any character outside the range A to Z is


Is Null OR Not Like "*[!a-z]*"
only rejected. (Case insensitive.)

Any character outside the range 0 to 9 is


Accept digits (0 - 9)
Is Null OR Not Like "*[!0-9]*" rejected. (Decimal point and negative sign
only
rejected.)

Letters and spaces Is Null Or Not Like "*[!a-z OR


Punctuation and digits rejected.
only "" ""]*"

Digits and letters Is Null OR Not Like "*[!((a-z) Accepts A to Z and 0 to 9, but no
only or (0-9))]*" punctuation or other characters.

The question mark stands for one


Exactly 8 characters Is Null OR Like "????????"
MHC Dilla character.
Campus
Is Null OR Between 1000 And
For Number fields.
Exactly 4 digits 9999
Is Null OR Like "####" For Text fields.
Remove the "=" if zero is not
Positive numbers only Is Null OR >= 0
allowed either.

100% is 1. Use 0 instead of -1


No more than 100% Is Null OR Between -1 And 1 if negative percentages are not
allowed.

Not a future date Is Null OR <= Date()

Requires at least one character,


Is Null OR ((Like "*?@?*.?*") @, at least one character, dot, at
Email address AND least one character. Space,
(Not Like "*[ ,;]*")) comma, and semicolon are not
permitted.

Same as setting the


field's Required property, but
You must fill in Field1 Not Null lets you create a custom
message (in the Validation
MHC Dilla Campus Text property.)
It is better to use a lookup
table for the list, but this may
Is Null OR "M" Or "F"
be useful for simple choices
Limit to specific choices such as Male/Female.

The IN operator may be


Is Null OR IN (1, 2, 4, 8)
simpler than several ORs.

The Yes/No field in Access


does not support Null as other
databases do. To simulate a
real Yes/No/Null data type,
Yes/No/Null field Is Null OR 0 or -1
use a Number field (size
Integer) with this rule.
(Access uses 0 for False, and -
1 for True.)

MHC Dilla Campus


Data Validation Examples
Validation Rule Description
<100 Must be less than 100.

<=100 Must be less than or equal to 100.

Between 1 and 10 Must be between 1 and 10.

<>0 Must not be 0.,Enter a nonzero value


<1/1/95 Must be a date after 1/1/95.

>=Date() Must be today’s date or after.

<=Date() Must be today’s date or earlier.

“Business” or “Pleasure” or
Must be “Business” or “Pleasure” or “Other.”
“Other”

Like “??” Must have two characters.


MHC Dilla Campus
Like “####” Must have four digits.
Validation rule Validation text

>=0 Value must be zero or greater. -or- You must


enter a positive number.

0 or >100 Value must be either 0 or greater than 100.

<#01/01/2007# Enter a date before 2007.

>=#01/01/2007# AND <#01/01/2008# Date must occur in 2007.

<Date() Birth date cannot be in the future.

MHC Dilla Campus


StrComp(UCase([LastName]), Data in a field named LastName must be
[LastName],0) = 0 uppercase.

>=Int(Now()) Enter today's date.

M Or F Enter M for male or F for female.

LIKE "[A-Z]*@[A-Z].com" OR "[A- Enter a valid .com, .net, or .org e-mail


Z]*@[A-Z].net" OR "[A-Z]*@[A-Z].org" address.

[RequiredDate]<=[OrderDate]+30 Enter a required date that occurs no more


than 30 days after the order date.

[EndDate]>=[StartDate] Enter an ending date on or after the start


date.
MHC Dilla Campus
Validation Text
 Validation Text : Used to specify the
message that will be displayed to the
user when data that violates the
validation rule is entered.

MHC Dilla Campus


Field Properties
Input Masks
 An input mask controls the value of a
record and sets it in a specific format.
They are similar to the Format property,
but instead display the format on the
datasheet before the data is entered.

MHC Dilla Campus


Field Properties
 In Microsoft Access, an input mask is a feature that allows
you to define a specific format for data entry in a field.
 It ensures that the data entered conforms to a pre-defined
pattern or structure, improving accuracy and consistency.
 They define the allowable characters, their positions, and
any separators or symbols used in the input.
 For example, if you have a field for phone numbers, you
can use an input mask to enforce a specific format such as
"(123) 456-7890".
 The input mask would automatically insert parentheses,
space, and hyphens in the appropriate positions as the user
enters the digits.
 Overall, input masks help to streamline data entry,
minimize errors, and ensureMHC Dilla Campus
consistency in the formatting
Field Properties
1. In design view, place the cursor in the
field that the input mask will be applied
to.
2. Click in the white space following Input
Mask under the General tab.
3. Click the "..." button to use the wizard.
4. Then finally select the format that you
wish to set.

MHC Dilla Campus


Captions
 In Microsoft Access, a caption is a label
or title that can be assigned to a field,
control, or object on a form or report.
 Captions are used to provide a
descriptive or explanatory text, making
it easier for users to understand the
purpose or content of a particular
element in the database.
 They can be customized and are
typically displayed alongside the
associated field orMHC
control.
Dilla Campus
Require
 The 'Require Field' property is used in
Microsoft Access to ensure that a specific
field in a table is not left blank or empty.
 When this property is set to 'Yes', Access
will display an error message if a user
tries to save a record without entering a
value in the required field.
 This helps enforce data integrity and
ensures that important information is not
missing from the database.
MHC Dilla Campus
Revision exercise
 Create the following table by adjusting
appropriate filed property and data type
for each fields

DID FNAME LNAME SALARY MARRIED?

Mhc-001 ABEL yonas ($5,000.00) Yes

Mhc-002 MULUNEH firew $12,000.00 Yes

Mhc-003 DAWIT alemu $8,000.00 No

Mhc-004 ETAGEGN shigute $9,500.00 Yes

MHC Dilla Campus

You might also like