Stop second Access

G

Guest

I have button on my main switchboard that starts a RunApp macro similar to
"C:\PathToWord\Winword.exe" "C:\PathToDoc\BankLetter.doc
that looks back to Access to get a table called "Signers" to do a mail merge with BankLetter.doc

The problem is that Word seems to then start a second instance of Access and my database to get to the Signers table. So, I then have two instances of Access running, both with the same database.

Is there a way to stop this? If Access is already open, I don't want/need a second instance of Access
 
C

Cheryl Fischer

I believe the info at the following link applies to your situation:

http://www.mvps.org/access/bugs/bugs0011.htm



--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


Glen said:
I have button on my main switchboard that starts a RunApp macro similar to:
"C:\PathToWord\Winword.exe" "C:\PathToDoc\BankLetter.doc"
that looks back to Access to get a table called "Signers" to do a mail merge with BankLetter.doc.

The problem is that Word seems to then start a second instance of Access
and my database to get to the Signers table. So, I then have two instances
of Access running, both with the same database.
 
C

Cheryl Fischer

Glen,

Here is what I suggest you do to test whether or not you like this
technique:

1. Create a New Macro (name it MailRun2 or somesuch)
2. For the Action, use: RunCode
3. In the lower left corner of the Macro Design view, you will see a line
for Function. Click on that line and, if you want, press Shift-F2 to open a
window for it. Insert the following:

fMailMerge ("C:\PathToDoc\BankLetter.doc", "TABLE Bank", "Select * from
[Bank]")

4. Save and close the Macro
5. Now, use the following code to replace the fMailMerge() function. I
have modified this function so that you can use it in more than one mail
merge process without editing it. Notice that in the first line of the
Function, that there are three arguments. These correspond to the string
values above for Name of Document, Object providing the data, and SQL string
for returning the data.

Function fMailMerge(strDoc As String, strConn As String, strSQL As String)
Dim objWord As Word.Document

If fSetAccessCaption Then
On Error Resume Next

Set objWord = GetObject(strDoc, "Word.Document")

objWord.Application.Visible = True

objWord.MailMerge.OpenDataSource _
Name:=CurrentDb.Name, _
LinkToSource:=True, _
Connection:=strConn, _
SQLStatement:=strSQL
objWord.MailMerge.Execute

'restore the caption
Call sRestoreTitle
End If
End Function


hth,
--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


Glen said:
Cheryl,

Thanks for your reply. I'm not 100% sure how to use the module that you
linked to. Right now I have button that calls a macro that I call MailRun
that basically includes:
"C:\PathToWord\Winword.exe" "C:\PathToDoc\BankLetter.doc"

Do I stop using that macro and use Function fMailMerge() instead? For that
function, I would substitute the above info for stMergeDoc and Set objWord?
The fMailMerge() function calls Function fSetAccessCaption() and Sub
sRestoreTitle()-not me?
 

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