|
|||||
|
Access
Hints and Tips
|
|||||
|
Introduction This page is intended for in-house developers and is intended to give you a modest amount of guidance on the development of Access databases. |
|
History |
|
Which Version To Use? |
|
Some Basic Tips and Hints |
|
Design your database tables properly. Spend time and effort getting this right.
If your underlying database structure is wrong then everything you do
subsequently will be made much harder and may not even function at all. Make
sure your foundations are solid, don't build a major database system on sand!
If you don't understand about database design then hire someone who does! Table
design issues to look out for include using the correct data types (eg don't
use a numeric field for a telephone number and use the date type for dates or
times rather than a string), use indexing correctly, make sure the design is
'normalized'.
|
| Aside: Roughly speaking a normalized database is one where the data in each
table is only related to the main ( = primary) key of the table and where any
duplicate data definitions are removed. For example if you are taking orders
then you would NOT have one table containing OrderNumber, OrderDate,
ClientName, ClientAddress, OrderDesc1, OrderValue1, OrderDesc2, OrderValue2,
...etc but instead would have perhaps three tables; one containing OrderNumber
and OrderDate, one for Client Details and one for the Order Details. This is a
gross simplification but should give you the general idea. It is vitally
important that your underlying database design is correct! |
| By all means use the wizards but don't rely on them to produce the full answer.
The wizards are fine if you want a quick and simple database that happens to
meet one of the supplied scenarios but don't try to take them too far. If you
want something more advanced or that does not match up with one of the
pre-defined templates then you must look at the underlying structures and make
sure these will work with your proposed solution. The Query Design wizard
however is great and you will find this immensely useful in making SQL more
approachable (and if you are saying "what's SQL" then you need to do a lot more
training before tackling any significant database work).
|
|
Learn and use VBA. With Access 97 and 2000 you can completely forget about macro's (with earlier versions of Access you still had to use macro's for a few functions). Macro's are OK (if you like that sort of thing) but they can be quite limiting; for example you cannot include any error trapping within a macro, so if a macro has a problem then your application just crashes without warning! If you want to do any serious development using Access you must use the proper programming language (all of our code is done using VBA - we hardly ever use macro's). |
| Split your database into two (at least). Keep all of your code, forms, reports,
etc. in one 'code' database and all of your tables in another 'data' database
which is then linked to the 'code' database. This makes modifications, updates
and back-ups that much easier and allows you to work on a new version of your
'code' database without affecting existing users. It also makes it easier
should you wish to convert a single user databases into a multi-user networked
version.
|
|
Don't use spaces, quotes or other punctuation characters within your field
names. Stick to A-Z, a-z, 0-9 and the underscore ( _ ). Access allows you to
use most punctuation within field names but the use of single or double quotes
can mess up SQL and cause your queries to fail - especially when you are
constructing them in VBA based upon data in a variable (eg FieldName = '" &
VarName & "'...). Spaces and other punctuation will work most of the time,
but you must then remember to enclose these field names in square brackets.
Additionally if you export data to another package, or if you later want to
convert to client/server, you may find that the other software won't accept the
field names. Best avoided - it saves heartache later on! |
| Make sure you put in adequate error trapping and that you test the final
solution properly. |
| Don't be over enthusiastic with the color palette. A limited number of subtle
colors are usually more effective than glaring purples and fluorescent greens. |
| Learn how to the use the debugging tools effectively. Access 97 and 2000
especially have got some cracking debugging aids. Make sure at the very least
you know how to single step through code and display the contents of variables. |
| Be wary about using ocx's/Active-X add-in components with care unless you know
what you are doing. These components (they keep on changing their name) can be
highly useful but are often incompletely documented and may cause problems. For
example they can work fine on your development machine but then refuse to work
when you create a run-time and install it on another machine. Having said that
they also offer an easy way to extend the power and flexibility of Access when
you get them right! Just remember, we did warn you! |
| OK, that's about it for now - Is there anything else that you'd like to see
added? What, some code samples! Well, ....... all
right. But just a few,... we can't be giving all our secrets away!!!
|
|
Dates |
|
And Finally.... |
|
Copyright ©2004, Aldex Software Ltd. |