Thanks Sprinks. I must be doing it wrong because I can not get it to
work. :(
My main form is where I enter the data about the job I am currently
doing ie project name, project address, specification etc. At the
moment because my database is very basic I am entering in every clients
details with all of that other data. I have made a table that has all
my clients names, phone numbers, addresses which I would like to
utilise so I dont have to enter the clients details for every record on
my main form. Am I going about this the right way? Is combo box the way
to go save me time or should I try something else. All I want to be
able to do is select a client so there details are automatically
inserted into the current record. What is the best way to utilise the
table that has all my clients details?
Thanks
FrunkaBlunka,
Like many new relational database users, you're getting hung up on what is
*displayed* in *controls* on a form and what is *stored* in *fields* in a
table. Tables should follow normalization rules--see references below. A
normalized application is efficient and easy to maintain. I urge you to
master the basic rules--they're not difficult--before you go any further.
One rule is that you don't store information redundantly from one table to
another. A Clients table should have a structure something like:
Clients
-------------------------
ClientID AutoNumber (Primary Key)
ClientName Text
Address
Phone
City
State
Zip
Fax
Website
...
other Client-specific fields
A Projects table should store information specific to each project. One of
these pieces of information is the client. To identify the client, you need
store only the ClientID from the Clients table, called a "foreign key" in the
Projects table, because it corresponds to the primary key of another table.
Since the primary key of Clients is an AutoNumber, the ClientID in Projects
must be of the Long Integer type.
However, who remembers or even cares about a ClientID number? We're much
more comfortable dealing with a client name. That's where a combo box comes
in. Several key combo box properties drive its behavior. If the
RowSourceType is a Table/Query (nearly all cases), the RowSource property is
an SQL statement selecting one or more rows of a table or query, such as:
SELECT Clients.ClientID, Clients.ClientName FROM Clients ORDER BY
Clients.ClientName;
The ControlSource is the name of the field in the form's underlying
recordset where the combo selection is stored. Following the earlier
discussion, this should be ClientID of the Projects table.
The BoundColumn property determines which column is stored in the field
specified in the ControlSource. Since we want to store the ClientID, this
should be 1.
The ColumnWidths property determines how much display space is allocated to
each column. If the first column width is set to 0", it will not be
displayed in the drop-down list, and the first non-zero-width column will
display once a selection is made. In this way, the user can efficiently
*store* the numeric foreign key, but never see it nor need to know it exists!
He will be looking solely at a list of names.
If you base your main form on a query as I suggested, once the ClientID is
stored, the form can display the other Client fields.
If this discussion doesn't help resolve your problem, please post:
- Your table structures (fieldnames, fieldtypes, primary keys)
- Your form's RecordSource. If it is based on a query, please post the SQL
(from query design view, choose View, SQL, and cut and paste the statement
- Your combo box' name, ControlSource, RowSource, BoundColumn, &
ColumnWidths properties
- Key properties of any subforms
Sprinks
> Thanks Sprinks. I must be doing it wrong because I can not get it to
> work. :(
[quoted text clipped - 12 lines]
>
> Thanks
FrunkaBlunka - 02 Aug 2006 05:08 GMT
Thanks Sprinks I worked it out. I am self taught, but I have learnt a
great deal from these forums. Thanks again
> FrunkaBlunka,
>
[quoted text clipped - 82 lines]
> >
> > Thanks