Database Maintenance, Import, and Export |
|
Practical Learning: Setting Default Values |
|||||
Validation Rule |
A validate rule is a condition that the value entered in a field must meet in order to be valid. This rule is usually created as an expression and entered in the Validation Rule property of a field when the table or the form is opened in Design View.
Practical Learning: Setting Validation Rules
Validation Text |
When the condition in the Validation Rule field is not respected, you can display a message box to let the user know. The message for that text box can be created as a string in the Validation Text field.
Practical Learning: Creating a Validation Text
Value Required for a Field |
If you think that there must be an entry for a particular field for each record, you can let Microsoft Access know. The Required property is Boolean value. If you set it to Yes, the user would not be able to move to the next record until he has entered a valid data in the field. Its default value is No. |
Practical Learning: Specifying Required Fields
|
Indexed Fields |
When data is entered in fields, it is possible to have the same value for a field in different records, such as two people who live in the same state. This is considered as a duplicate value. In some other cases, this may not be acceptable. For example, you may not want two employees to have the same employee number. This characteristic can be set using the Indexed property that provides 3 values:
|
Practical Learning: Controlling Indexed Fields
|
Data Import/Export |
Introduction |
Importing data allows you to get information from an external source and insert it in your database. Microsoft Access can accept data from various applications, and with a little trick, you can import even from unfriendly applications. Before importing data, you must make sure that it is in a format Microsoft Access can read; even if that data is coming from another application of the Microsoft Office suite. |
Practical Learning: Introducing Data Import
|
Import/Export With Text Files |
As you are already familiar with Microsoft Access functionality, you know that a cell is delimited with gridlines. If you intend to import a text document, format it so that Microsoft Access can recognize where a field starts and where it ends. Such a file can be created with Notepad. This delimiter is usually done by pressing Tab when creating the fields' content and pressing Enter at the end of each record. Instead of the Tab key, you can also use a comma or a semi-colon to separate two fields. Since a field is usually made of more than one word (such as an address), enclose the content of each field in double quotes, as in "1600 Pennsylvania Avenue". |
Practical Learning: Importing a Text Document
|
Import/Export With Microsoft Access Objects |
Microsoft Access objects are probably the easiest objects to import because, created with of the same application, these objects are already formatted and recognizable. To import objects from another Microsoft Access database, you can use the main menu or the New Table dialog box. |
Practical Learning: Importing a Microsoft Access Object
|
Database Objects Linking |
Linking data allows you to connect your database to an external document. Such a table can have its data accessed directly or modified in Microsoft Access. When linking data, since you are making it available to the database, make sure that Microsoft Access can "read" it; otherwise it would not recognize its content. The main reason you link data is to treat your database as one file despite its belonging to another document. Linking to a spreadsheet is usually a straightforward process. Linking to a word processing document usually involves performing a mail merge. |
Practical Learning: Linking to a Microsoft Access Object
|
Import/Export/Linking With Spreadsheet Files |
When creating a spreadsheet in Microsoft Excel for data import, you have two alternatives. You can create the column headers at the very top of the worksheet and type a data field in each corresponding column. Alternatively, you can create data as on a table, and then create a name range that holds the information you need in the database. To import a Microsoft Excel spreadsheet, on the main menu, you can click File -> Get External Data -> Import. Locate the file that holds the spreadsheet and click Import. You would be asked to specify what to import, a whole spreadsheet or a named range. |
Practical Learning: Linking to a Spreadsheet
|
Import/Export With Microsoft Outlook |
Importing a Microsoft Outlook document is mainly done on the address book level and is as smooth as what we have seen so far. All you have to do is have the address book already created and you are ready to go. The following exercise is not supposed to be performed here; it is provided as a guide
|
Saving a Database Object As a Web Page |
Microsoft Access allows you to create a web page based of your database. The process of doing this is different from one version of Microsoft Access to another. We will cover only Microsoft Access 2000. |
Practical Learning: Exporting a Database Object as HTML
|
Mail Merge |
Mail merging allows you to use data on your database to create letters, labels, envelopes, and other documents that require external data originating from another document. When performing a mail merge, you usually do not need all the fields that are part of a table. Although you can use all fields on a table, it is recommended that you create a query made only of fields you need for your document. This would include the name and address of the recipient. Perform the following exercise only if you have Microsoft Word |
Practical Learning: Merging Data With Microsoft Word
Considerations on Data Entry |
The Computer Regional Settings |
The information in a database is stored in tables, although you will usually not allow users to get access to such objects. The table is therefore the most principal means of data entry. The computer controls how it is supposed to display some pieces of information such as date and time values. These also affect internal settings of databases and other programs used on a computer. To view, control or set these properties, the computer bases its decisions on the Regional Settings dialog box from the Control Panel window. To review the Regional Settings of your computer, you can click Start -> Settings -> Control Panel. If you are using MS WinXP, you can click Start -> Control Panel. From the Control Panel window, you can double-click Regional Settings. If you are using WinXP, click Regional and Language Options. Click each of the property pages: Number, Currency, Date, and Time |
Practical Learning: Using the Computer's Regional Settings
|
The Office Clipboard |
If you are using Microsoft Access 97, skip this section |
The computer clipboard is a non-spatial object used to temporarily hold a piece of data. In fact, it is one form of memory in which you can store information to be retrieved. The word temporary implies two things. First, the clipboard can hold its data only as long as the computer is On. If you turn the computer Off, the clipboard gets emptied and looses its data. Second, the clipboard can hold only one type of data. The good news is that the clipboard is not strictly confined to one type of information. This means that it can hold a picture (any type) OR text (any length), anything. This was the behavior of the classic clipboard. Microsoft Access 2000 brought tremendous improvement to the clipboard. The new Microsoft Office clipboard can hold up to 12 items. Each item is independent of the others and can individually be anything. In fact, information held by one of these memories can origin from any application. To use Microsoft Office Clipboard, you should first display it. To do this, you can first open an object such as a table or a form. Then, on the main menu, you can click View -> Toolbars -> Clipboard. To copy an object to the clipboard, you can just press Ctrl + C or Edit -> Copy from the main menu. You can also select something and then click Copy on the Clipboard toolbar. |
The Size of a Database |
A database is primarily a computer file, just like those created with other applications. As such, it occupies an amount of space in the computer memory. In some circumstances, you should know how much space your product is using. This can be important when you need to back it up or when it is time to distribute it. Also, when adding and deleting objects from your database, its file can grow or shrink without your direct intervention. |
Practical Learning: Checking the Size of a Database File
|
Deleting Database Objects |
As we have seen so far, there are various reasons you create objects in your database. Some will be made part of the final product. Some others are used to test conditions, values, data entry, etc. When such temporary objects are not needed anymore, you can delete them. To delete a table, we learned that you could use the DROP TABLE expression in a SQL statement and specify the name of the table. To delete any database object (table, query, form, etc), you can click to select it, and then press Delete. Unlike some other database environments (like Corel Paradox), a Microsoft Access table is not a stand-alone object, which means you cannot access it as its own entity outside of its database. For this reason, when you delete a database object such as a table or a form, it does not go into the Recycle Bin. Therefore, the deleting action is irreversible. Whenever in doubt, do not delete a database object, especially a table. |
Practical Learning: Deleting a Database
|
Compact and Repair of a Database |
As mentioned already, once you have created a database file, it occupies a certain amount of memory space that can grow or shrink without your direct intervention: When you add an object to the database, the database's file grows as needed. When you remove an object, the memory space it was occupying is left empty. This also applies when you keep removing objects: The computer is supposed to recuperate the space those previous objects were using. Unfortunately, that is not the case. Most of the time, that space is left empty but cannot be accessed by the computer. This means that the memory space cannot be made available to other applications. To recover this memory space, you can compact the database. When this is done, the file is shrunk to occupy only the necessary amount of space and free the unused sections: To compact a database, on the main menu, you can click Tools -> Database Utilities -> Compact and Repair (in Microsoft Access 97, the Compact Database and the Repair Database are separate menu items). |
Practical Learning: Compacting a Database
|
Maintenance of Imported Objects |
Like most other computer applications, a database is a product that can benefit from regular revisions and improvements. There are various operations related to database maintenance, including renaming objects, changing the sequence of fields, applying customers’ feed back. We have already performed some of these actions such as renaming fields of a table in Datasheet View and in Design View. Whenever you import a database object from an external source, to be understood by Microsoft Access, its data field would receive some configuration that you may not like. For this reason, after importing a table from a text file or from a Microsoft Excel spreadsheet, you should review it in Design View and customize the fields if necessary. Most of the time, each text field imported would be assigned a field size of 255 characters. If a field in numeric, you should review it and specify the appropriate numeric data type. If you import a spreadsheet a field hold monetary values, its field would be translated with the Currency data type. Microsoft Excel and text files do not have the concept of AutoNumber. When importing data from an external source, if you want to use an AutoNumber field on the new object, you should let Microsoft Access create a new field as the Primary Key. In this case, Microsoft Access would also create it as AutoNumber. If you decide to create your own primary key and if the object already contains data, you cannot change it to an AutoNumber. If you link your database to an external object, you should not modify its structure because your database is not supposed to control this. Your database in this type of scenario is mainly used for data entry. This is why you should make a decision between importing and linking. |
Practical Learning: Customizing Imported Objects
|
Data Objects Backups |
If you are working on a complex database and need to perform some tests on it, you should avoid use the original objects as a test might mess them. The alternative is to create a copy of either the object or the database itself. It is important to remember that data resides on tables. For this reason, if you copy a form or query and change the data, for example if you delete a record, the record would be deleted from the database. If you copy a table and make record changes on the new table, you would be safe because such a table would have a new and independent set of records. To make a backup copy of any object that is part of your database, you can right-click it and click Copy. Then right click the same window and click Paste. Since two objects (of the same category) cannot have the same name, a dialog box would display to request a new and different name for the object you are copying. |
Practical Learning: Backing Up Database Objects
|
Database Backup |
When working regularly with a database, you should always make a backup of your database, in case something bad happens like a computer complete crash where you may not be able to recover. In most cases too, especially if you have a customer whose product you have developed, you should make a copy of the database to give away while keeping the original. |
You can also make a backup copy of a database to distribute either to colleagues, employees, students, or customers, etc. In this case, you can copy it from Windows Explorer or My Computer and paste it in the floppy drive. If the database is too large, such as the current Bethesda Car Rental (because it has grown a lot after adding the pictures), it would not fit in one floppy disk. In such case, you can zip it using zip software and possibly spread it on various floppy disks. The best alternative is probably to put on a CD-ROM. Since most computers nowadays ship with a CD Writer, this should not be difficult to do. If you have a more advanced backup system for your computer, you can also use it regular to backup your database. As backup systems are different, if you have one, it would give you the information you need to proceed. The following exercises are completely optional. |
Practical Learning: Backing Up a Database
|
MDE Files |
If you have created a database and decide to distribute it or to give it to a customer, colleagues or employees, they may be tempted to open the forms in Design View and possibly modify their structures. There are two disadvantages to such an action. They may compromise or corrupt your hard, possibly rendering obsolete. Some bad eye may decide to cheat on your hard work VBA code. Microsoft Access allows you to make some or most of these actions difficult or impossible. An MDE file is a database compiled by Microsoft Access so the users of the database cannot change the design of forms or reports, create new forms or reports, view its VBA code, or import forms, reports or VBA code. To create an MDE file of your database, after opening it, on the main menu, you can click Tools -> Database Utilities -> Make MDE File… |
Practical Learning: Creating an MDE File
|
MOUS Topics |
S21 | Use the Office Clipboard |
S42 | Import data to a new table |
S43 | Save a table, query, or form as a Web page |
S46 | Back-up and restore a database |
S47 | Compact and repair a database |
Exercises |
Yugo National Bank
|
Watts A Loan
|
|
||
Previous | Copyright © 2002-2019, FunctionX | Next |
|