Re: Using a query as a data source for a mail merge
- From: "Peter Jamieson" <pjj@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 20 Jan 2007 00:06:23 -0000
What is the SQL code for the query?
code, before it debugs to say it can't find the database, it asks me to
login as a user.
When you open your database using Access, are you prompted for a (database)
password? Or are you promted for a username and password (workgroup
security)? Or do you start your database using a command line or icon that
specifies either of those two things?
BTW, are you the Cavey Rescue guys in Kent I visited with Brigid & Ralph
last summer? If so, feel free to despam my e-mail and e-mail directly.
Peter Jamieson
"Ultraviolet47" <ultraviolet47@xxxxxxxxxxxxxx> wrote in message
news:1169232300.085832.182700@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello everyone.
I have used a table as a datasource to mail merge in Word 2003 from
Access 2003. Now I need to change this to a query. I have altered the
code that references the table and changed it to the query name
(Qry_WelcomeLetter), but it says Word cannot find the data source.
Another curious thing that happens is when I execute the merge via this
code, before it debugs to say it can't find the database, it asks me to
login as a user. I have gotten this message previously, but thought
that was because I had not set Word to become visible. I then added the
code to make Word visible and after a few weeks of peace it's asking me
for a user name and password for Admin again?
ANy ideas to stop the username request and how to get it to recognise
the data souce?
Here is my code:
Private Sub Print_Welcome_Letter_Click()
Dim objWord As Object
Set objWord = GetObject("C:\Documents and Settings\Stel\My
Documents\Cavy\Sponsorship pack\Sponsors\welcome letter.doc",
"Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Rat Rescue database.
objWord.MailMerge.OpenDataSource _
Name:="C:\Documents and Settings\Stel\My
Documents\Cavy\Sponsorship pack\Sponsors\CavyRescue.mdb", _
LinkToSource:=True, _
Connection:="QUERY Qry_WelcomeLetter", _
SQLStatement:="SELECT * FROM Qry_WelcomeLetter WHERE SponsorID =
(SELECT Max(SponsorID) FROM Qry_WelcomeLetter)"
objWord.MailMerge.Destination = SendToNewDocument
objWord.MailMerge.Execute
'The following line must follow the Execute statement because the
'PrintBackground property is available only when a document window is
'active. Without this line of code, the function will end before Word
'can print the merged document.
objWord.Application.Options.PrintBackground = False
objWord.Application.ActiveDocument.PrintOut
End Sub
.
- Follow-Ups:
- Re: Using a query as a data source for a mail merge
- From: Ultraviolet47
- Re: Using a query as a data source for a mail merge
- References:
- Using a query as a data source for a mail merge
- From: Ultraviolet47
- Using a query as a data source for a mail merge
- Prev by Date: Re: I am having problems doing a mail merge between word & excel
- Next by Date: Re: Access to Word Merge - missing £sign
- Previous by thread: Using a query as a data source for a mail merge
- Next by thread: Re: Using a query as a data source for a mail merge
- Index(es):
Relevant Pages
|