 | 
28-Jul-2006, 08:29 AM
|  | Guest | | | | | | | | | | Avoiding "Data Link" during Word merge In Access 2003, I am using VB to build a complex MAKE TABLE query,
store it in a new Query Def, then execute it to make the table. I then
launch a Word mail merge using that new table as the data source. The
Word template is not bound to a data source.
When I run the code, Word shows the Data Link window asking for a data
source. Trying to cancel says the data source is already open, but the
merge runs anyway. This happens often, but not always, and I can't
tell what causes it.
Is the complex MAKE TABLE simply not finished creating when the merge
executes? The merge to Word in VB seems so flakey; it works, but often
throws generic errors. Below is a code excerpt. Any ideas? Thanks.
Set qdfMake = db.CreateQueryDef("", strSQL)
qdfMake.Parameters(0) = Eval(strCtlOID)
qdfMake.Execute
appWord.Visible = True
objWord.MailMerge.OpenDataSource Name:="E:\data.mdb",
LinkToSource:=True, Connection:="TABLE tbltempOutputReport",
SQLStatement:="SELECT * FROM [tbltempOutputReport]" Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/12420-avoiding-data-link-during-word-merge.html
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12420 Got anything to share on This Topic? Why not share your immediate thoughts/reaction with us! Login Now! or Sign Up Today! to share your views... Gurfateh! | 
28-Jul-2006, 08:29 AM
|  | Guest | | | | | | | | | | Re: Avoiding "Data Link" during Word merge Some brainstorms that I'll look into:
Is there a WaitUntil or PauseUntil statement that won't advance until a
condition is met?
Or maybe pause with a Do While loop until the condition is met?
Does qdf.Execute have a return value for the above pause statements?
Does the database's Tables collection send a signal when a new table is Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12420
added, which could be watched for by a pause statement?
Could a pause statement check that the table exists AND is populated
before going on?
Show a dialog box after table creation but before merge, making the
user click OK to do the merge? That's one more step than I'd like,
though.
The other error that I sometimes get during the merge is maybe from
Word, saying the data source is empty or has no records. Sure, because
the query is not done creating the table when it tries to do the merge.
Is there a standard solution to this? Thanks. Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12420 cjg.groups@gmail.com wrote:
> In Access 2003, I am using VB to build a complex MAKE TABLE query,
> store it in a new Query Def, then execute it to make the table. I then
> launch a Word mail merge using that new table as the data source. The
> Word template is not bound to a data source.
>
> When I run the code, Word shows the Data Link window asking for a data
> source. Trying to cancel says the data source is already open, but the
> merge runs anyway. This happens often, but not always, and I can't
> tell what causes it.
>
> Is the complex MAKE TABLE simply not finished creating when the merge
> executes? The merge to Word in VB seems so flakey; it works, but often
> throws generic errors. Below is a code excerpt. Any ideas? Thanks.
>
>
> Set qdfMake = db.CreateQueryDef("", strSQL)
> qdfMake.Parameters(0) = Eval(strCtlOID)
> qdfMake.Execute
>
> appWord.Visible = True
> objWord.MailMerge.OpenDataSource Name:="E:\data.mdb",
> LinkToSource:=True, Connection:="TABLE tbltempOutputReport",
> SQLStatement:="SELECT * FROM [tbltempOutputReport]"
> objWord.MailMerge.Destination = wdSendToNewDocument
> objWord.MailMerge.Execute | 
28-Jul-2006, 08:29 AM
|  | Guest | | | | | | | | | | Re: Avoiding "Data Link" during Word merge Hi Albert,
All is working fine now. It appears word started on one occasion and
stalled, so each time I tried it again it thought word was open.
Simply cleared the temp file word created and that sorted it.
Great little tool, many thanks
Les
"Albert D.Kallal" wrote in message
news:uLxAEsjnGHA.2364@TK2MSFTNGP02.phx.gbl...
> For some reason, often the word directly does not get created correctly. Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12420
>
> Try creating a dir called "word", and then try my example..... Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12420
>
> However, since you were able to create a template, then likely the dir did
> get created.
>
> Were you able to create a template, and add a few fields using my example?
>
>
> --
> Albert D. Kallal (Access MVP)
> Edmonton, Alberta Canada
> pleaseNOOSpamKallal@msn.com
> http://www.members.shaw.ca/AlbertKallal
> | 
Support Us! Become a Promoter! | | Gurfateh ji, you can become a SPN Promoter by Donating as little as $10 each month. With limited resources & high operational costs, your donations make it possible for us to deliver a quality website and spread the teachings of the Sri Guru Granth Sahib Ji, to serve & uplift humanity. Every contribution counts. Donate Generously. Gurfateh! | (View-All)
Members who have read this thread : 0
| | There are no names to display. | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Tools | Search | | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is On | | | | » Active Discussions | | | | | | | | | | | | | | | | | | | | | | | | | Amrit Yesterday 09:17 AM 5 Replies, 364 Views | | | | | » Books You Should Read... | | | |