A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Mail merge using Albert Kallal



 
 
Thread Tools Display Modes
  #1  
Old June 6th, 2008, 05:34 AM posted to microsoft.public.access.gettingstarted
Jens
external usenet poster
 
Posts: 33
Default Mail merge using Albert Kallal

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.
--
Jens
  #2  
Old June 6th, 2008, 07:31 AM posted to microsoft.public.access.gettingstarted
Albert D. Kallal
external usenet poster
 
Posts: 2,874
Default Mail merge using Albert 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).


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada



  #3  
Old June 6th, 2008, 08:15 AM posted to microsoft.public.access.gettingstarted
Jens
external usenet poster
 
Posts: 33
Default Mail merge using Albert Kallal

Thaks for the reply, worked straight away
--
Jens


"Albert D. Kallal" wrote:

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).


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:50 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.