Best way to view subform info? (1 Viewer)

shacket

Registered User.
Local time
Today, 22:56
Joined
Dec 19, 2000
Messages
218
I have tables that are linked to my main tables by the primary key. The main table lists the person's name, but the "secondary" table (because it is linked) only lists the primary key.

What is the better way, when viewing the secondary table information, to have the person's name (from the main table) appear on the form?

1. Use a subform

OR

2. Use code in the OnCurrent event to find the person in the main table and populate an unbound text box with their name

Thanks.

Dave
 

sbornstein1

Registered User.
Local time
Today, 22:56
Joined
Jun 19, 2001
Messages
24
Your question makes no sense. Can you explain in more detail what your trying to do.
 

shacket

Registered User.
Local time
Today, 22:56
Joined
Dec 19, 2000
Messages
218
Sorry. Here is the story:

Table 1 has:

ID...Name
4....John Smith


Table 2 is a linked table with other information (say, John Smith's orders). So table 2 only lists John Smith's primary Key (4).

When viewing the orders table (in a form), I want, when viewing John Smith's order, to show his name (which is not stored in the orders table, but linked through the Primary Key).

There are two ways to do this:

1. Use a subform

2. In the OnCurrent event of the orders form, have code look up the primary key (4) in the first table and populate a text box with the name (John Smith).

Both would work. I am simply wondering if one is more efficient or recommended than the other.
 

pcs

Registered User.
Local time
Today, 16:56
Joined
May 19, 2001
Messages
398
i always use a subform for this kind of thing. that way, on the main form, i can let the user select a customer from a combo box and display some of the customer data from the customer table. after selection the subform then displays the data from the orders table.

from an efficiency standpoint, it probably makes little difference, unless you use a Dlookup to get the customer name and you have a whole lot of customers...

hth,
al
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 17:56
Joined
Feb 19, 2002
Messages
43,484
Whenever you want to show data from the secondary table, you can use a query that joins to the main table to pick up the person's name. This is what relational databases are all about. Separating the data into individual tables that eliminate the duplicating of data so that update anomolies are prevented and then joining them back using queries for reporting.
 

shacket

Registered User.
Local time
Today, 22:56
Joined
Dec 19, 2000
Messages
218
I suppose a query is a 3rd way to accomplish this. I had been using the combo box idea listed above, but because the user does not choose who the record is associated with, the database spent time filling a combo box that was unneccessary to fill.

Pat: would a query be faster (or "better")than using VB in this situation?
 

Users who are viewing this thread

Top Bottom