Xem bản tiếng việt đầy đủ tại đây : http://thethao60s.com/index/1537576/13072008.aspx

MS Access - Bai 6: Tao bang trong Access
Bat dau voi Table Wizard

Truoc khi bat dau voi Table Wizard, phai chac chan nut Tables da duoc chon trong cua so Database (man hinh hien thi nhu hinh 1). Sau do, kich dup chuot vao Create Table By Using Wizard. Ngay lap tuc, ban se thay hop thoai Table Wizard hien thi nhu hinh 2. Trong hop thoai nay, Access hoi ban de lua chon kieu bang ma ban muon tao


Hinh 1: Cua so Database


Hinh 2: Lua chon loai bang de tao

Truoc khi lua chon mot loai bang, hay danh mot phut de nhin vao hop thoai Table Wizard. Hop thoai nay cung giong cac hop thoai Wizard khac: phia tren cung la mot vai thong tin tro giup, o giua la noi thuc hien cac su lua chon, phia duoi la cac nut dieu khien. Ban su dung nhung nut nay de di chuyen tu buoc nay toi buoc khac. Muc dich cua cac nut nay duoc trinh bay trong bang 1.

Cac nut

Y nghia

Cancel

Dung Wizard, khong co thao tac nao duoc thuc hien

Back

Tro lai buoc truoc do (neu co)

Next

Chuyen sang buoc tiep theo (neu co)

Finish

Ket thuc Wizard; hoan thanh cac thao tac voi thong tin san co

Bang 1: Cac nut dieu khien Wizard

Chu y rang tai cua so hien tai thi chi co mot nut dieu khien la hien huu, cac nut khac thi bi mo di. Access thuc hien nut dieu khien hien huu nay tai thoi diem hien hanh. Do vay, nut Back khong sang boi vi khong co buoc truoc; luc nay ban dang o buoc dau tien. Nut Next va Finish cung khong sang boi ban can phai thuc hien mot vai lua chon truoc khi tien trinh Wirard co the thuc hien.

Chon mot loai bang

Tai buoc dac biet cua Table Wizard nay, Access hoi ban de xac dinh loai bang ban muon tao. Chu y rang co 2 lua chon la Business va Presonal o phan giua cua phia ben trai hop thoai. Nut ma ban lua chon se anh huong toi cac kieu bang liet ke trong danh sach Sample Tables. Trong bai nay, lua chon nut Business. co rat nhieu bang mau khac nhau trong duoc liet ke, ban co the xem tat ca bang cach su dung thanh cuon phia ben phai Sample Tables. Bang 2 mieu ta cac bang mau khac nhau khi tich chon nut Business ma Table Wizard se tao.

Bang mau

Y nghia

Mailing List

Tao mot danh sach dia chi thu don gian hoac phuc  tap

Contacts

Bang kiem tra su lien he viec ban hang

Customers

Bang quan ly cac khanh hang doanh nghiep.

Employees

Luu tru thong tin ve cac nhan vien cua cong ty, co the lam viec voi cac bang mau Expenses va Time Bill

Products

Trien khai viec kiem ke co so du lieu

Orders

Theo doi don dat hang cac san pham

Order Details

Theo doi chi tiet don dat hang (nhung muc hang rieng le), nhung cong viec lien quan toi bang mau Orders.

Suppliers

Theo doi cac dai ly.

Categories

Xay dung mot danh sach cac loai ma ban co the su dung chung voi cac bang khac.

Payments

Cac ban ghi thanh toan boi khach hang.

Invoices

Luu tru thong tin ve cac hoa don duoc tra.

Invoice Details

Theo doi chi tiet cac hoa don (nhung muc hang rieng), nhung viec lien quan toi bang mau Invoices.

Projects

Theo doi cac du an ma ban hoac cac nhan vien dang thuc hien; nhung cong viec lien quan toi file mau Time Billed

Events

Dua ra danh sach cac su kien dac biet, ket hop voi bang mau Reservations.

Reservations

Quan ly nhung han che cho cac su kien dac biet; ket hop voi bang mau Events.

Time Billed

Theo doi thoi gian da tieu ton cua cac du an, ket hop cac bang mau Projects, Employess, va Expenses.

Expenses

Luu tru mot su viec ve cac chi phi lien quan toi cac du an, ket hop voi cac bang mau Projects va Employees

Deliveries

Theo doi viec phan phoi cac san pham, co the ket hop voi cac bang mau Customers, Orders, Employees.

Fixed Assets

Mo rong danh sach nhung bat dong san boi cong ty ban.

Service Records

Logs khi mot dich vu duoc thuc hien tren asset; co the lam viec voi cac bang mau Fixed Assets va Employees.

Transactions

Luu tru ban ghi cua doanh nghiep da thuc hien cac giao dich; co the lam viec voi bang mau Payments.

Tasks

Kiem tra danh sach cac nhiem vu da hoan thanh.

Employees And Tasks

Thiet lap moi quan he giua cac bang Employees va Tasks

Students

Luu tru thong tin ve sinh vien (hoac nhan vien) va lop hoc cua ho.

Students And Classes

Thiet lap moi quan he giua bang Students va Classes.

Bang 2: Cac bang Business co the duoc tao bang Table Wizard

 

Chu y: Sample tables duoc su dung trong Table Wizard chi la cac bang mau. Tuy nhien, ban co the sua doi chung mot chut trong khi su dung Table Wizard. Sau do thay doi thiet ke cua bang da duoc tao.

Khi ban muon tao mot co so du lieu cua nhung nguoi rieng biet, chi can chon loai Personal. De lua chon cac bang mau cua nhom nay, kich chuot vao nut chon Personal. Access thay doi danh sach cua cac bang mau nhu hinh 3.


Hinh 3: Table Wizard sau khi hien thi cac mau co so du lieu Personal.

Su dung thanh cuon ban se thay Table Wizard co the duoc tao tu nhieu bang khac nhau. Mot so danh sach trong bang (bang 3)

Bang vi du

Y nghia

Addresses

Tao mot danh sach dia chi thu cho moi nguoi

Guests

Kiem tra cac khach duoc moi toi mot su kien xa hoi

Categories

Xay dung mot danh sach ma ban su dung cung voi cac bang khac.

Household Inventory

Luu giu mot ban ghi cho cac muc dich bao hiem.

Recipes

Quan ly cac mon an yeu thich, nuoc xot va cac cong thuc lam.

Plants

Theo doi qua trinh trong cay trong nha kinh hay ngoai vuon.

Exercise Log

Luu lai nhung bai tap ban da hoan thanh va chua hoan thanh.

Diet Log

Theo doi che do an kieng cua ban theo tung bua.

Wine List

Theo doi cac loai ruou vang yeu thich va loai nho lam ruou vang.

Rolls of Film

Luu giu cac cuon phim ban chup anh, co the su dung no voi mot bang mau Photographs.

Photographs

Luu tru mot ban cac buc anh; ban co the su dung voi bang mau Rolls of Film.

Authors

Liet ke cac tac gia ban yeu thich, co the su dung voi bang mau Book collection.

Books

Kiem tra cac loai sach trong thu vien ca nhan, co the su dung voi bang mau Authors.

Groups

Liet ke nhom cac anh chup va bat ky thong tin nao ban co ve chung.

Service Records

Logs khi mot dich vu duoc thuc hien ve mot tai san; voi su thay doi nao do, bang nay co the lam viec voi bang mau Household Inventory.

Recording Artists

Liet ke cac nghe si ban yeu thich, co the su dung voi bang Recordings.

Recordings

Ghi lai cac ban nhac; co the su dung voi bang Artists.

Video Collection

Tap hop cac bang dia va dia laser.

Accounts

Quan ly cac tai khoan dau tu; duoc ket hop voi bang Investments.

Investments

Theo doi su dau tu rieng le; duoc ket hop voi bang Accounts.

Bang 3: Cac bang mau muc Personal duoc tao voi Table Wizard

Rat nhanh de lua chon cac bang mau khac nhau. Khi su dung chuot de chon ten cac bang mau do, Access se thay doi thong tin o danh sach Sample Fields.

De tao mot bang luu giu thong tin ve ten, dia chi, so dien thoai cua nhung nguoi ban, chon Addresses trong danh sach Sample Tables (Dieu thuan loi khi chon muc nay la no da duoc danh dau san, do la su lua chon dau tien trong danh sach). Luc nay, chi can chon cac truong ma ban muon dua vao trong bang. Man hinh hien thi nhu hinh 3.

Lua chon cac thong tin

Trong mot bang, ban se chi dinh cac truong, hay cac phan thong tin de theo doi. O cot giua, nhan Sample Fields, la noi xac dinh cac truong de dua vao trong bang. O chuong 1, cac truong duoc dinh nghia la loai thong tin luu giu cac ban ghi trong bang. Do vay, tai muc chon Addresses, ban chi dinh cac truong de luu giu thong tin cho moi nguoi. Bang 3 trinh bay cac truong tu su chon lua cua ban.

Cac truong

Y nghia

AddressID

Mot so ID co dinh cho dia chi.

FirstName

Ten cua ban

LastName

Ho cua ban

SpouseName

Ten cua vo hoac chong.

ChildrenNames

Ten cac con.

Address

Dia chi khu pho dang o.

City

Dia chi thanh pho.

StateOrProvince

Bang hoac tinh

PostalCode

Ma buu dien

Country

Ten nuoc

EmailAddress

Dia chi hom thu dien tu tren Internet, dich vu thong tin truc tuyen,…

HomePhone

So dien thoai nha rieng.

WorkPhone

So dien thoai noi lam viec.

WorkExtension

 So may nhanh tai phong lam viec

MobilePhone

So dien thoai di dong

FaxNumber

So Fax

Birthdate

Ngay sinh

SendCard

Mot thong bao ve viec co gui thiep sinh nhat toi nguoi ban nay hay khong.

DateLastTalkedTo

Ngay gan day nhat ban lien he voi moi nguoi

DateUpdated

Ngay thay doi ban ghi co so du lieu gan day nhat.

Nickname

Nicknames (biet danh) hoac ten duoc uu tien.

Notes

Nhung binh luan va chu thich.

Hobbies

Nhung thoi quen hoac so thich

HealthIssues

Van de suc khoe

Photograph

Mot buc anh cua ban

Bang 4: Cac truong san co cho bang mau Addresses

Table Wizard cung cap 25 sample fields (cac truong mau) cho bang Addresses. Tuy nhien, ban khong can su dung tat ca cac truong nay. Thay vao do, chi can lay cac truong can thiet. Va nho la, chi can luu giu thong tin hop ly.

De chon mot truong, danh dau ten truong va kich chuot vao nut co bieu tuong (>). Lan luot, cac truong duoc chon se di chuyen sang cot thu 3 (Fields In My New Table – Cac truong trong bang moi) trong hop thoai. Ban muon bang gom it nhat truong ten rieng, ten ho, dia chi, so dien thoai, thi danh dau vao cac truong nay trong danh sach Sample Fields. Sau moi truong duoc chon, kich chuot vao nut >. Khi da hoan thanh, hop thoai nhu hinh 4.


Hinh 4: Sau khi dinh ro cac truong cho bang

Neu gap loi nao do thi khong lo. Ban co the su dung cac nut o giua cot thu 2 va cot thu 3 de dua cac truong khong muon trong bang tro lai. Bang 3 liet ke cac nut va muc dich cua chung.

Nut

Muc dich

Dua mot truong tu cot Sample Fields sang bang

>> 

Dua tat ca cac truong tu cot Sample Fields sang bang

Di chuyen mot truong tu bang ve Sample Fields

<< 

Di chuyen tat ca cac truong tu bang ve Sample Fields

Bang 5: Cac nut lua chon truong

 

Chu y: Ban co the di chuyen cac truong trong mot bang bang cach loai bo va sau do them chung mot lan nua. Access them mot truong da duoc chon vao bang ngay ngay duoi truong da duoc danh dau trong cot 3.

Hay gop bat cu truong nao ma ban nghi la can thiet cho bang. Thuc hien nhung thay doi cho den khi hoan thanh viec xac dinh ro cac truong. Truoc khi lam tiep, phai chac chan ban da them truong AddressID vao trong bang, truong nay duoc gan la khoa chinh. Trong hai phan tiep theo ban se duoc biet su quan trong cua viec them truong AddressID. Khi da hoan thanh, kich chuot vao nut Next de chuyen sang buoc tiep theo. Access hien thi hop thoai nhu hinh 5.


Hinh 5: Hop thoai tiep theo trong Table Wizard

Dat ten cho bang

Ban da gan hoan thanh viec xac dinh bang. Tuy nhien, Access can biet mot chut phan du lieu truoc khi duoc tien hanh. Phia tren cua hop thoai, Access se hoi ban ten cua bang. Khong duoc nham ten bang nay voi ten ban da dat cho co so du lieu khi tao lan dau. O day ban dang dat ten bang va co so du lieu duoc tao co the chua nhieu bang. De minh hoa vi du nay, ban chap nhan mac dinh ten (Addresses).

Trong hop thoai nay, ban cung chi ro lieu ban co muon Access su dung mot khoa chinh cho bang. Khoa chinh la mot truong ma Access su dung de sap xep bang. Thong thuong, mot khoa chinh la duy nhat, nghia la chi co mot ban ghi voi duy nhat mot ma khoa chinh, Access se khong cho phep ban them mot ban ghi neu no trung voi khoa chinh o ban ghi khac.

Vi du, neu ban co 3 nguoi ban co cung ho Smith, ban khong the su dung ten ho la khoa chinh. Tuong tu nhu vay, neu tat ca deu song o Seattle, ban khong the su dung thanh pho la mot khoa chinh. Tuy nhien, ho co cac so dien thoai rieng co dinh nen co the su dung truong dien thoai lam khoa chinh.

Ban co the dat khoa chinh theo mot trong hai cach. Access tu thiet lap mot khoa cho ban (day la truong hop mac dinh), hoac ban chi dinh khoa. Thuc hien theo lua chon cua ban sau do kich chuot nut Next.

 

Tim hieu ve khoa

Mot khoa chinh duoc xac dinh de Access sap xep thong tin trong bang. Mac du ban khong can dinh nghia khoa chinh, Access se thuc hien chuc nang nay co hieu qua hon neu ban dinh nghia khoa chinh do. Su dung mot khoa chinh, Access co the dinh vi va hien thi ban ghi rat nhanh. Thuc hien su cai tien nay se rat quan trong khi ban them nhieu ban ghi vao co so du lieu.

Access cho phep xac dinh ca khoa duy nhat lan khoa khong phai duy nhat. Su dung khoa duy nhat tot hon vi no cai thien duoc thoi gian tim kiem. Tuy nhien, co the co tinh huong khoa duy nhat la khong duoc. Vi du, ban muon dung ten thanh pho lam khoa. Mot khi co nhieu thanh pho cung ten do, ban muon chi ro khoa do khong phai la duy nhat

Ngoai ra, co the su dung nhieu truong de xac dinh khoa. Tuy nhien, ban khong the su dung Table Wizard de lam viec do. Thay vi vay, ban phai tao bang bang tay. Ban se hoc cach de lam duoc dieu nay trong chuong 4, “Tao co so du lieu khac”

Khi chon mot truong lam khoa chinh, ban nen lua chon truong gan nhu la duy nhat thi tot hon, bat chap viec ban cho phep lap lai hay khong. Vi du, ban khong muon su dung truong FirstName hoac LastName lam khoa chinh, do la truong co nhieu su lap lai. Mat khac, co the su dung truong HomePhone vi co it su lap lai hon.

Xac dinh mot khoa

Neu de Access tu dong xac dinh khoa chinh, ban co the bo qua muc nay va tien hanh o buoc tiep theo. Neu tu thiet lap khoa, se thay hop thoai xuat hien nhu hinh 6.


Hinh 6: Thiet lap khoa cho bang

Su dung hop thoai nay, co the lua chon truong ma Access su dung nhu khoa. Access goi y mot truong de su dung (do la truong dau tien trong bang), nhung co the lua chon mot truong khac bang cach kich chuot vao mui ten tro xuong phia ben phai truong. Minh hoa cho vi du nay, chac chan truong AddressID duoc chon.

 

Chu y: Neu ban quen gop truong AddressID trong bang, co the su dung nut Back de tro lai hop thoai xac dinh truong (Ban can kich chuot vao nut nay 2 lan). Them truong do va su dung nut Next de quay lai hop thoai nay.

Tiep theo, hop thoai yeu cau chi ro ban muon Access se xac dinh khoa nhu the nao  Co 3 lua chon:

Khoa chinh ban lua chon phu thuoc vao cach ban tien hanh su dung no nhu the nao. Neu chi can dem, lua chon muc dau tien (khoa ma co gia tri tuong ung cac so: 1, 2, 3,…). Tuy nhien, neu khoa chinh co yeu cau khac, hay chon mot trong cac tuy chon khac. Khi hoan thanh, kich chuot vao nut Next.

Ket thuc bang

De ket thuc tao bang, chi can tra loi hai cau hoi. Ca hai cau hoi deu lien quan den nhung gi ban muon lam khi Table Wizard hoan thanh. Hop thoai hinh 7.


Hinh 7: Ket thuc Table Wizard

Trong hop thoai nay, phai xac dinh ro la se lam gi tiep theo. Chon cac muc sau:

Trong chuong 9 “Tao bieu mau tuy y”, ban se hoc cach lam viec voi cac bieu mau. Con luc nay, chon muc thu hai (thuong la mac dinh). Neu ban thay can tung buoc de nam vung trong khi su dung Access, co the tich vao nut “Display Help on working with the table” de hien thi hop thoai Help.

Ngay khi ban kich chuot vao Finish (Nut Next luc nay khong sang vi khong co buoc tiep theo), Table Wizard tao bang theo nhung yeu cau cua ban. Ban se biet Wizard duoc hoan thanh khi thay che do Datasheet view cua bang hien thi len man hinh.

Ngan NT (Theo Learn Access)