Mail merge using Albert Kallal

J

Jens

Hi,

I am using source code from Albert Kallal mailmerge to insert data from an
Acces form to a word template. It works perfectly except for I have a combo
box to select the company, form displays the company name but the bound item
on the form is the companyID from a seperate table. When I perform the merge
only the companyID number is displayed and not the actual company name.
Any sujestions would be a great help.
 
A

Albert D. Kallal

What you need to do in this case is build query.

So what you do is fire up the query builder, and drop in your first table.

now drop in the table with a company.

now simply draw join line from that companied field to the company table.

For your query, simply drag the "*" from the 1st table into the query grid.
And, then drag and drop the company name from the 2nd table into the query
grid.

(save this query...*TRY* the query...make sure it works ok...

Now, in your form, behind the button go:

me.refresh

dim strSql as string
strSql = "select * from NameOfYourNewQuery where id = " & me!id
MergeAllWord strSql

The test I'm using the command called MergeAllWord. this allows you to
specify any SQL that you create in the query builder for the merge. however,
if we don't restrict it to the current records ID, that it would merge all
records in the database, and I don't think you want that.

Note in the above for the current record or form you were on, I'm assuming
that your primary key is "id", so if your primary key for the current record
form is different, then simply change the "id" in

where id = " & me!id

To whatever you're currently using.

do note that if you have several lookups (combo box etc) in your current
form where the ID is displayed, but you want the actual text description
from another table, you can drag and drop as many tables as you want into
the above query. do remember to double click on the "join" line that you
just drew between the tables, and ensured that it is a left join (otherwise,
records without a company name will not appear in this query, and it will
not work).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top