View Single Post
  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Ultraviolet47 Ultraviolet47 is offline
external usenet poster
 
Posts: 3
Default Using a query as a data source for a mail merge

Hi

I'm making this db for Cavy Rescue (and my rat Becky!) It's not been
fully implemented, just ironing out testing bugs.

There is a database password, but there is no workgroup security set.

I am asked to run the SQL command, so select Yes when prompted.
It then pops up a "Data link proprties tab" with the User Name Admin in
and the file path of the db, I deselect "blank password" and enter the
database password.

It then comes up with a new Authorize prompt, asking for Admin password
again, so enter db password again.

It then mail merges and prints.

Is there any way to avoid having to enter password (twice!), without
actually getting rid of the password itself?

Thanks for your help.

Peter Jamieson wrote:
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" wrote in message
oups.com...
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