Académique Documents
Professionnel Documents
Culture Documents
Table Stuff
Relational Database
Access supports a database composed of tables that adhere to the relational model and that are
normalized, i.e., in the third normal form. Consult Wikipedia for an explanation of database
normalization. You will encounter frustrating problems creating forms, reports, and queries
when your database is not normalized. Get your data model right!
Primary Key(s)
The role of the primary key (PK) is to identify the field(s) that uniquely identify a record. Access
automatically prevents duplicate or null values from being entered in PK fields.
To set a PK in table design view:
1. Select the field(s). To select only one field, click its row selector. To select 2+ fields, hold
down the [Ctrl] key and click the row selector for each field.
2. Click the PK icon in the Table Design Toolbar or select menu Edit, Primary Key.
Indexes
Indexes have pros and cons:
they speed finding records by SELECT queries
they slow append queries (because the index must be maintained too).
An index can be established for 1 to as many as 10 fields.
It can be helpful to create an index for key queries. An index is automatically created for the PK
and for autonumber fields. An index can be defined as unique and to ignore nulls (which
excludes records from the index whose indexed field contains Null values). An index has a sort
order based on the sequence of the fields in the index; each field can be ASC or DSC.
Empty a Table
Do with a query:
DELETE * FROM [table name];
The columns in the list are the fields in the database.
The column labels in the list are the field names in the database.
Each row in the list is a record in the database.
There are a few restrictions:
The XLS file can have only one worksheet.
The XLS file must have the same type of data in each field (column)
The XLS file must have the same fields in every row.
Only one heading row in the XLS file.
If you import into an existing table, the XLS file column headings must match the table field
names.
If you import into an existing table, the XLS file column must have the same data type as
table fields. Since XLS file columns don’t really have data types, you mayhave to finagle
getting a number into a text field (put a letter in the field in the first record, then delete it
from the table).
I suspect that the size of the table field must be large enough to hold the XLS cell. Not sure
what happens if this is not true.
Hyperlinks
Per Microsoft: If you create a table by importing data, Microsoft Access automatically converts
any column that contains URLs (an address that specifies a protocol such as HTTP or FILE and a
full filename or website address, for example: http://www.microsoft.com/) or UNCs (a name with
the syntax \\server\share\path\filename) paths into a hyperlink field. Access will convert the
column only if all the values start with a recognized protocol, such as “http:” or “\\.” If any
value starts with an unrecognized protocol, Access wonʹt convert the column into a hyperlink
field.
But what about an existing table?
In an Access table a valid hyperlink has the form displaytext#address#subaddress#screentip
where the address part either includes the protocol (e.g., “file:”) or is a UNC. When a field has
data type Hyperlink, after you import data into it, the hyperlink has no address (href) and
consequently has no effect. If you run a query like:
UPDATE CandidateFiles SET URL = URL + “#” + URL + “#”
the hyperlink becomes operative. This will not work if the field’s data type is Text.
If the value of a Text field has the form displaytext#address#subaddress#screentip, all the text
appears as the field value and there is no operative hyperlink. When the field’s data type is
changed to Hyperlink, then the hyperlinks looks and operates correctly.
DoCmd.SetWarnings True
End Sub