Word merge pulls from wrong table column

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Albert Kallal's WordMerge is working very nicely now but I have a problem
with one mergefield:
I have an Employees table and a field on the form with a dropdown and that
enables the relevant name to be displayed.
I have set the template mergefield to be the EmployeeName, which is stored
in full in one of the table columns. However, when I do the merge, I get the
ID number from the Employee table and not the name.
I guess I have got something wrong in terms of which column the merge is
supposed to look at - what am I doing wrong, please?
Many thanks.
 
Well, in most cases, a combo box will store the "id", but display the text
from another table.

If you need that text from the other table, then base your form on a query,
and simply join in that table that the combo box uses. If you have 5 other
combo boxes and 5 other tables..then simply drop in those 5 additional
tables, and draw the appropoate join lines. Then, include all of the fields
from the main table, and the descriptions from the additional "child"
tables.

when you run the word merge, you will see both the "id" field used, and also
the description field used.....

Remember, for each of the additional tables that you drop into the query
builder, you must click on the join line and change it to a left join...

A left join means that a query will return the "parent" records when the
child table HAS NO correspond record.

So, if we have Customers, and Invoices tables, a left join would give us:

CustomerName InvoiceNumber
AppleBee
Donought Shop 1234
Doughnut Shop 1344

Note how AppleBee does NOT yet have a invoice number in the invoices
table..but the query still returns the record. You have to use left joins
for lookup values when you drop in many tables (can't use standard joins in
this case).

So, with a left join, the corresponding child record DOES NOT have to exist.
Just think of "left" side can exist...but the right side does NOT have to !

A middle join, or so called inner join is the standard join, and BOTH tables
have to have a value for the join. The above would produce:

CustomerName InvoiceNumber
Dounought Shop 1234
Doughutn Ship 1344

So, in the above inner join, our customer name of Applebee does not show,
since that customer does NOT yet have a invoice record in the invoice table.

To make a left join, you drop in the tables (in the query builder, or the
relationship designer), and draw the join line to the appropriate filed
between each table. You then double click on the join line. You then click
on the join type button

You get three options:

Only include rows where the joined fields from both tables are equal
(this standard default inner join)

Include ALL records from "Customers" and only those records from
"Invoices" where the joined fields are equal

(this is our left join. So, our main table Customers will be returned in
this query, REGARDLESS if the child records (invoices in this example)
exist, or not!. This is left join

Include ALL records from "Invoices" and only those records from
"Customers" where the joined fields are equal
This sis obviously a right join....

For forms, and sub-forms, and related tables, left joins are quite
important.
 
Albert, you're a star. You have fed me info on several other queries that
were entering my mind too. Thanks so very much!!
 
Back
Top