Merge issue using Albert Kallal's code

S

Serena

Hi there

I am using AK's code for triggering a mail merge for Access (from URL below)
and so far it was working brilliantly.

(http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html)

However, I have changed the data source for one of my templates, and I
cannot get the code to recognise the new source - I have reset the data
source endlessly and even tried deleting the template and recreating it to no
avail.

I can quite happily run the Mail Merge directly from Word and it works fine,
but if I trigger it from AK's form, it comes up and tells me that a number of
fields aren't available and the list of fields it shows are from the table I
originally used. This tends to confirm that the issue is a variable
somewhere in the code but I haven't been able to find it.

This issue has persisted through an overnight shut-down of the PC so wonder
if the info is stored in an object (e.g. the mail merge form perhaps).

Can anyone help me pinpoint this error please ?

Thanks for any help.
 
A

Albert D. Kallal

I have changed the data source for one of my templates

You don't mention how you done the above? If you using my system, then you
MUST use my system to set the datasouce.
I have reset the data
source endlessly and even tried deleting the template and recreating it to
no
avail.

How are you doing the above re-set of the data source? Stop and think for a
second! How does/did the temploates know where to get their data from
before? answer: my code + system sets the data source. Since you were NEVER
setting the data source before, then it stands to reason that the merge
system sets the datasource for you. So, if you go and change the data source
of a template then my code is going to simply set it back to whatever form
you have.

If you want, you can re-create the tempalte, but once again what was the
data source used when you made the template? So, make sure you using the
option "add new templte" from my system, and it will ensure that your data
source is SET CORRECT for you.

The "default" data source is ALWAYS the form you are looking at and that
forms data is what the template data source is set to. The merge has always
worked this way, and that very much why the system is so simple (you NEVER
have to set the data source of the merge yourself).

In a nutshell all the above simply means that it quite obvious that my merge
system been setting the data source all along since you never had to do it
before. If you come along and now change the data source of that document,
then my code is going to continue to change it back to the current form you
are using...

If want to use a data source OTHER then the current form you launching, then
use "mergeAllWord" command in place of "MergesingleWord".

eg:
dim strSql as string

strSql = "select * from MyCoolQuery where city = 'Edmonton'"

MergeAllWord strSql

in the above, you can see that we can specify a table, or even a query, and
even have conditions in that query as above. This query is then used as the
data source for your word templates. So, the above is how you can change the
data source of the merge.....

There is some additional options on how to merge, or even print the word
documents here:
http://www.members.shaw.ca/AlbertKallal/wordmerge/page2.html

About the only rule for specify sql or query as a data source is the
query/sql must be free of any parameter prompts, but as you can see in the
above how I restricted the merge to one city..it generally not a problem or
limitation of not being able to use parameters..
 

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