IntroductionYou will find in the tables three important elements of a database; the list of fields, the properties of each one and the data that's in them.Tables are structured. The structure contains the list of fields as well as the properties or the characteristics of these fields. This page gives you not only the information to create of a table, but also how add and change fields in it. The first part of this page consists of creating a table to keep some information about the employees of a company. You will see in this way all the stages for the creation and the management of a table. At the time of the creation of your tables for your needs, don't especially forget the phase of analysis. A good analysis in depth of your needs and the data that you need to reach your expectations can at the end save you time and escalations a lot. This phase is explained in more details on Access's introduction page. Before we begin, here are some explanations on the fields of the table Employees. Every recording of the table should have the name and the First name of the person. The post is the occupation that the person occupies in the company. For this example, there are only two types of occupation: the managers and the salesmen. The field office(desk) indicates the office location. For this company, there are employees in Montreal and in Quebec. The managers work according to a salary whereas the salesmen work only on commission. To end, it is necessary to have the date of hiring of the employee. Here is the list of the fields of the table Employees so that the compulsory characteristics. Besides giving a name to the field, it is necessary to determine it a type and, in most of the boxes, the size. It is necessary to indicate the size of fields according to the number of characters that you want to keep in these fields.
Create a tableThis exercise consists in creating a table that contains of the information about the employees of a company. Before even entering of the information, it is necessary to give a structure to this table. It is necessary to determine a list of fields as well as the characteristics of these fields. It is only after this stage that it will be possible to enter of the information.
Access offers you several ways to create a table of data. The mode worksheet shows you a grid in that you write simply the information that you want to keep. You can then choose the mode creation to change the options that Access had determined for you. The mode creation contains all the options to create and personalize the structure of a table of data. The assistant Banks gives you of the assistant to the creation of a table by asking you to choose among a list of fields that you will find mostly in a table. You can also import a table from another base of datum of Access or even a working sheet of Excel. The last option allows you to make(do) a link for another table of another data base and to reach its information.
1. Give a name to the fieldDuring the addition of a field in the structure of a table, it is necessary to give it a name and a type of field. According to the type of field, it is also necessary to indicate to Access the number of characters that you want to protect in the field. You can also, in your choice, add a comment to give more information about the contents of the field.
The types of fieldsAccess the choice between several types of field gives you
In the choice of the user, it is also possible to add a description. This is practical when you return some months later and want to know why you chose to have these fields in the table. This description is also going to appear in the left lower corner of the window at the time of the entry or the modification of the data. The properties of the fieldAt the bottom of the screen, there are the characteristics or the properties of the field. Each is practical under the circumstances. The next part explains each of these properties and when these are practical. You can also fetch more information about one of the properties below by placing the pointer on this one and by pressing on the key F1.
These last properties are those that are available for the fields of type Text. Here are some available supplementary properties for the other types of fields.
To have more information about the properties of fields:
Access's assistant will show you the information that it possesses on this property. Primary keyA primary key is a field, or a series of fields, that helps to differentiate a recording of all the others of the table. For example, one can use the number of social assurance to differentiate each from the employees of the company. There is no two that are identical. One can also use a number of inventory to differentiate each of the products of the others etc. A primary key can also consist of several fields. As long as the combination of field differentiates a recording of the others. For example, one can add a booking knowing that there will be two persons who will appear at the same time with the same name. If it would be the box, it would be necessary to add another field to the primary key to differentiate them. Or, one could simply create a field No. of booking to solve the problem. The use of several fields to compose a primary key is very rare but possible. The method to insert the primary key on one or several fields of the table will be explained a little farther on this page; at the time of the modification of the table. Secondary keyA secondary key is a field that is connected with the primary key of another table. For example, the field of the table Charges can be connected with the key No. of customer of the table Customers. Save the structure of the tableHaving created a table, it is necessary to keep it.
Access will ask you that is the name of the new table.
Access goes possiblement to ask you if you want to add a primary key to your table. For the moment, this table does not need primary key. It will be added a little farther on this page.
Data entryNow the structure of the table is defined, it is possible to enter of the useful information for the user; data. To begin, there are data on the four employees of the office(desk) of Montreal. The next stage consists in entering these data the table.
Access will show you a grid to enter the data just like this one but without the data.
Note: The last row of a table or a query always shows one "*" in the grey box to the left of the row. This is to indicate the end of this one. enter figures without the signs $. In the laboratory, enter dates size(format) year ( 2 figures), month, day with a hyphen among each. Insert a mask of seizureA mask of seizure is to indicate to Access the way that the information entered a table. You can force the user to enter the data in a certain way. For example, it is unthinkable to have letters in a phone number or a social number of assurance. Also, a postal code is a series of letters and figures. How to make sure that the data will have entered in a right way? It is for that reason that there are the masks of seizure. Access already has some sizes (models) for the data that you will find mostly in a data base. The next part is to demonstrate how to reach you these models. You will apply it according to your needs in your own tables.
At the end of the box, a button with three little dots inside has just appeared.
Access is maybe going to ask you to protect your table before being able to continue. protect it. If Access asks you also for a primary key, for the needs of the exercise, don't add it for the moment. The window with the list of the models has just appeared.
There are several models. Each is for a different occasion. You can use them to enter a phone number up to a password.
The following window will appear.
This window shows you the mask of seizure. You can experiment by writing of the text in the box To try. It is possible to you to change the size(format) of the mask of seizure better to answer your needs. By placing the cursor in the box Masks of seizure and by pressing on the key F1, you will have a list of the possibilities for the size(format) of the mask of seizure. This list is very detailed and should be read attentively.
Access asks you then how that the information will be stored in the field: with or without the symbols of the mask of seizure (the brackets, the spaces as well as the hyphens).
A last window should appear to indicate you that the creation of the mask of seizure is ended.
Add a mask of seizureThe previous option how showed to use the masks of existing seizures. But, it is also possible to you to add your own masks of seizures better to answer your needs. The text that follows shows the stages to be followed to create a new mask of seizure. The next exercise will create a new mask of seizure for a code of inventory. This code consists of three letters, a hyphen and four figures.
A window will appear of whom(that,what) all the boxes will be empty. It is to you to enter the name of the mask of seizure, its presentation, if there are reserved spaces. You can even add an example of the mask of seizure.
You can add as many masks of seizure as you want. Insert a Valid ifThe property Confirms If allows to put limits or borders in the entered of data. For example, there are very few persons who like working for a salary or a negative commission. The exercise consists in demonstrating ValideSi's functioning by using it not to allow negative values fields Salary and Commission.
The properties of the field will appear in the section of bottom.
It is in this case that you put the criteria of validation. You can use various operators (= >, <, < =, > =, < >, Among and, or, Not...) to create the criterion of validation. For the exercise, it is necessary to make sure that the value that entered the field is not negative.
In the exercise, it is possible that a person earns no salary or no commission according to the occupation of the employee in the company. The managers earn only a salary whereas the salesmen earn only a commission on sales. So, it is possible to have a salary or a commission equal to zero. The box Message if error is the text that will appear to the screen when the contents of the field respect the criteria of validation. In that box, if the user enters a negative figure.
The next time that you will enter or will modify the contents of the records, try to enter a negative value to see the result. Modify the tableAfter a while, you will notice that changes are necessary for a table. It needs new fields. Or, certain fields need to be modified or simply eliminated.
For the example, it is necessary to add four new fields: Numéro of poste (Employee's ID number), status, permanent status and comments. The field Numéro of poste (Employee's ID number) will be used to differentiate each of the records. It will be the primary key of the table. Furthermore, the field Numéro of poste (Employee's ID number) will be inserted at the beginning of the structure of the table. The field Status will serve for saving the marital status of the employee. This field will be the Numeric type. It's going to keep the marial status according to a number: 1 = bachelor(single woman), 2 = married without dependent, 3 = married with dependent, 4 = divorced, 5 = divorced with family allowance. So, the only valid rags are 1 and 5. It will be also used during the creation of a form. The field Permanent will be the type Yes/No. It's going to determine if the person with receipt its permanent status in the company. The field Comment will be of type memo. It will be possible to write comments, about the performance of each from the employees of the company.
Insert a field
A new free row will appear. The other rows will be moved downward.
Move a fieldTo change the order of presentation of fields
The field will re-fit into the structure of the table between both fields among that the row that separates it is more thick as soon as you will release the mouse button. Delete a field
Place the primary key
The primary key is a field, or a series of fields, that allows to distinguish each of the records. Every person in its social number of assurance, a number of customer or employee. It can consist of letters or figures. One of the things that Access verifies later is to make sure that there are two records that will have the same information in the field. For example, two persons can have the same number of social assurance or two products the same number of products. Access will not allow the creation of the primary key if two records have the same information in the chosen field. If you need absolutely that both records have the same information, it would be necessary to consider another field, or combination of fields, for the primary key of the table. A table is not obliged to have a primary key. It needs however a primary key if the other tables want to reach the information of this table. For example, the table Charges its address and the other information could, thanks to the relations between tables, reach the information of the table Customers to know the name of the customer. So, to find more quickly the information and to make sure that there are two customers with the customers' same number, it is necessary that the field Customer's number of the table Customers is the primary key of this table. For this exercise, the new field Numéro of poste (Employee's ID number) will be the primary key of the table.
The key placed in the box intoxicates to the left of the field Numéro of poste (Employee's ID number) confirms that the primary key is on this field. If by mistake, you chose the bad field as the primary key, press the Place a primary key on several fieldsA primary key can also consist of several fields. There are even occasions where it is necessary to have a primary key in this way. For this exercise, the primary key will consist of fields First name, Name and Date of hiring.
Here is the final result. The key placed in the grey box confirms that the primary key consists of fields First name, Name and Hiring. It means that it is possible to register several times the same value in one of the fields. But it is impossible to register several times the same values in all the fields that compose the primary key at the same time. For example, it is impossible to have two persons with the same First name and name that are hired at the same time.
Adding recordsbring the additions to the already created records and add the other records to your table.
Sorting the recordsAt the time of showing the contents of the table in mode sheet of data, the option of the sorting shows the records in increasing or lessening order according to a field. In the sheet of data mode, you will find in the toolbar the following
buttons:
All the records will be shown according to the order for that you asked on the field where is the pointer at this moment. The filterThe option of the filter allows only to show a part of the records: the one that answers the criteria that you determined before. This is very advantageous when the user wants to find quickly some records among a lot of data. From the sheet of data mode, you will find buttons to create, activate
and deactivate the filter on a table or a query: Creating a filterDetermine the criteria of selection. You can choose only to show a part of the records; those that answer certain criteria. The list of the fields of the table will appear the one next to another.
It remains only to put the criteria only to show the records that answer these conditions. The exercise consists of showing only the salesmen of the region of Quebec. So, will be needed two criteria: the one for the Occupation field and the other one for the Office field.
The list of choices makes easy to find the information. It only shows what is contained in the field. But, it is also possible to create its own criteria. For example, it is possible to know that earns a salary superior to 45 000 $ by putting the operation > 45000 below the Salary field. It is also possible to combine criteria. In this exercise, two criteria are combined. Occupation equals to salesperson AND Office equals in Quebec. Activate a filter
Access will show you the records that answer the criteria that you chose. Deactivate a filter
Print the structure of a table
The following window will appear.
The following window will appear.
Access will generate the state for that you asked. You can see it in the screen or print it: Export a tableAccess gives you the possibility of exporting the data of tables. These can be exported towards other data bases or in the size(format) of the other applications such as Excel or Word. You can in this way take advantage of the possibilities of these for calculations, analyses or mailing for example. It's to note however that it's better to export from the queries if you need only a part of the records and not the whole.
Access will create a new document with the data of tables in the size(format) that you chose. Import a tableImport's option allows you to go look for data resulting from the other data bases or from the other applications and to add them to your data base. The next exercise consists in importing data from a file Excel. If you have not already made it, protect the file demodb.xls from the page of the demonstration files on a floppy disk.
The next part presumes that you have to protect the file demodb.xls on a floppy disk.
Access needs to know from the worksheet of Excel about that you will find the data to be imported. For the exercise, these data on the sheet of work named Sheet1. There is no other information about this sheet other than the data to be imported. Otherwise, it would have been necessary to give a name to the block of cells containing the data to be imported. The assistant of import calls it the option " View the named(appointed) beaches ".
Access asks you if the data of the first row of the working sheet are the names of the fields of the table to matter. In that box, it is true that the data of the first row are the names of fields.
Access asks you if you want to create a new table to store these data and add them to a table that already exists. For the exercise, the data will be kept in a new table.
Access asks you now for more information about each of the fields, or columns, the data to matter. To change the properties of each of the fields, it is enough to click the grey box containing the name of the field. You can then change some properties such as the name, the indexation and if you want to import the field or not. If the first row of the data to be imported was not that with the name of fields, you can change it now by entering the name of your choice the box Name of the field. Even if you answered yes the question two windows before, you can again change the name better to answer your needs. Access asks you also if you want to index the field. Choices are not, yes with doubloon and yes without doubloon. This helps to sort out recording and so necessary during the relations between tables. It accelerates the access to the data in the connected tables. place a sorting only on the necessary fields for your needs. You slow down the presentation of the data when you place the sorting on several fields of the table. A last option gives you importer's choice only the fields that you need. It is still possible to you to exclude a field of the import. It is enough to choose the name of the field and to tick the box not to import the field. Access asks you then for that name you go to look to the table that you import. This implies that you don't import the data in a table that already exists. You have also the possibility of activating the assistant of analysis of structure. It analyzes the data and looks for halvings information. He asks you then if he can cut the data in several tables to have the most optimal possible structure of tables. For the purpose of the exercise, don't activate this option. You can also have of the supplementary assistant when the assistant in ended his work. Access will confirm you the import of the data according to the choices for that you asked.
Here is the result of the import if you open the table Employee 2. Linking a tableTo link a table to the data base the advantage gives you to reach data that are outside of this one without enlarging it for all that. You can also add or remove data of the outside table. The disadvantage is that you can not change the structure of this table. The next exercise consists in binding(connecting) the same table as you mattered in the previous exercise. Some of the stages to be followed to link a data base external look like those of the import.
The next part presumes that you have to protect the file demodb.xls on a floppy disk.
Access asks you if the data of the first row of the working sheet are the names of the fields of the table to matter. In that box, it is true that the data of the first row are the names of fields.
To end, Access asks you that is the name that you want to give to the attached table.
Access confirms you that the data of the working sheet Sheet1 of the file demodb.xls are now accessible from your data base. To differentiate the tables of the data base of those that are attached, Access places an arrow in front of the attached table. Because the data result from the Excel spreadsheet, the icon of the application appears also. |
| You like what you read?
Share it with your friends. |