PC Review


Reply
Thread Tools Rate Thread

Access Mail Merge in Word Data Link Error

 
 
omsoft
Guest
Posts: n/a
 
      10th Feb 2009
I am doing a mail merge to a Word template from an Access query. It is a
onClick event on a button. The code is as below.
It opens the Word template and then comes up with Data Link Properties
dialog. When I click OK, I get a message as below.
"The database has been placed in a state by user 'Admin' on machine 'MY'
that prevents it from being opened or locked."
When I click OK, it comes up with a Login dialog for MS Access database. If
I click OK, it will post the above message again. If I click Cancel, it goes
ahead with the merge.

Does anyone know how can I get rid of these messages? Thanks a million.

Dim strDir As String
Dim objWord As New Word.Application
Dim objDoc As Word.Document
strDir = getMDBPath
objWord.Application.Visible = True
Set objDoc = objWord.Documents.Open(strDocName)
objWord.Application.Visible = True

objDoc.MailMerge.OpenDataSource _
Name:=getThisDBPath(), _
LinkToSource:=True, AddToRecentFiles:=False, _
Connection:="QUERY qry_MailMerge_1", _
SQLStatement:="SELECT * FROM [qry_MailMerge_1]"
objDoc.MailMerge.Destination = wdSendToNewDocument
objDoc.MailMerge.Execute

objWord.Application.Documents(1).SaveAs (strMergedDocName & ".doc")
objWord.Application.Documents(2).Close wdDoNotSaveChanges
objWord.Application.Documents(1).Close wdSaveChanges
objWord.Quit
Set objWord = Nothing
Set objDoc = Nothing

 
Reply With Quote
 
 
 
 
omsoft
Guest
Posts: n/a
 
      10th Feb 2009
Fixed by saving the MDB file and doing a compact and repair.

"omsoft" wrote:

> I am doing a mail merge to a Word template from an Access query. It is a
> onClick event on a button. The code is as below.
> It opens the Word template and then comes up with Data Link Properties
> dialog. When I click OK, I get a message as below.
> "The database has been placed in a state by user 'Admin' on machine 'MY'
> that prevents it from being opened or locked."
> When I click OK, it comes up with a Login dialog for MS Access database. If
> I click OK, it will post the above message again. If I click Cancel, it goes
> ahead with the merge.
>
> Does anyone know how can I get rid of these messages? Thanks a million.
>
> Dim strDir As String
> Dim objWord As New Word.Application
> Dim objDoc As Word.Document
> strDir = getMDBPath
> objWord.Application.Visible = True
> Set objDoc = objWord.Documents.Open(strDocName)
> objWord.Application.Visible = True
>
> objDoc.MailMerge.OpenDataSource _
> Name:=getThisDBPath(), _
> LinkToSource:=True, AddToRecentFiles:=False, _
> Connection:="QUERY qry_MailMerge_1", _
> SQLStatement:="SELECT * FROM [qry_MailMerge_1]"
> objDoc.MailMerge.Destination = wdSendToNewDocument
> objDoc.MailMerge.Execute
>
> objWord.Application.Documents(1).SaveAs (strMergedDocName & ".doc")
> objWord.Application.Documents(2).Close wdDoNotSaveChanges
> objWord.Application.Documents(1).Close wdSaveChanges
> objWord.Quit
> Set objWord = Nothing
> Set objDoc = Nothing
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail Merge from Access - Word throws "Cannot Open Data Source" Error Eric Microsoft Access Forms 2 5th Jul 2010 01:56 AM
How to mail merge data into word from excel and link/produce chart =?Utf-8?B?cHN5IFVL?= Microsoft Excel Charting 0 29th Aug 2007 03:14 PM
Using an ODBC link table in MS Access query as data source for a Word mail merge jimr_1234567890 Microsoft Access External Data 0 26th Jul 2006 10:44 PM
Link excel and word in mail merge without losing your data source? =?Utf-8?B?YW5naWU=?= Microsoft Excel Misc 5 1st Jul 2005 06:29 PM
Access data to word mail merge Bruce Hawkins Microsoft Access Getting Started 1 25th Jun 2005 05:20 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:42 PM.