theConjurian
IS-IT--Management
I have an application that has been performing a mail merge successfully for some time. I recently performed the following structural changes to the database:
1. I converted from .mdb to .accdb
2. Later I split the application and database to frontend/backend which reverted the types to .mdb
In the process I started to get the error, "The Microsoft Access database engine cannot find the table or query 'contact_Select_Quer'
The relevant code follows:
With CurrentDb
If QueryExists("Contact_Select_Query") Then
.QueryDefs.Delete ("Contact_Select_Query")
End If
strContactSelect = "SELECT * FROM Contacts WHERE [Contacts].[ContactID] = " & Forms![Contacts Browse]!ContactID & ";"
Set qdfNew = .CreateQueryDef("Contact_Select_Query", strContactSelect)
.Close
End With
Call cmdFileDialog(doc, logCancelFlag)
If logCancelFlag = False Then
DoCmd.RunMacro "mcrHide"
Set objfso = CreateObject("Scripting.FileSystemObject")
Set objfile = objfso.GetFile(doc)
strFileName = objfso.GetFileName(objfile)
Set objWord = GetObject(doc)
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource _
Name:=CurrentDb.Name, _
SQLStatement:="SELECT * FROM Contact_Select_Query", _
SubType:=wdMergeSubTypeWord
' NOTE: The actual merge is executed manually
DoCmd.RunMacro "mcrShow"
End If
It appears as if Word is not getting the correct query name, even though I CAN connect to the query from Word after the connection fails. Can anyone suggest what might have changed?
1. I converted from .mdb to .accdb
2. Later I split the application and database to frontend/backend which reverted the types to .mdb
In the process I started to get the error, "The Microsoft Access database engine cannot find the table or query 'contact_Select_Quer'
The relevant code follows:
With CurrentDb
If QueryExists("Contact_Select_Query") Then
.QueryDefs.Delete ("Contact_Select_Query")
End If
strContactSelect = "SELECT * FROM Contacts WHERE [Contacts].[ContactID] = " & Forms![Contacts Browse]!ContactID & ";"
Set qdfNew = .CreateQueryDef("Contact_Select_Query", strContactSelect)
.Close
End With
Call cmdFileDialog(doc, logCancelFlag)
If logCancelFlag = False Then
DoCmd.RunMacro "mcrHide"
Set objfso = CreateObject("Scripting.FileSystemObject")
Set objfile = objfso.GetFile(doc)
strFileName = objfso.GetFileName(objfile)
Set objWord = GetObject(doc)
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource _
Name:=CurrentDb.Name, _
SQLStatement:="SELECT * FROM Contact_Select_Query", _
SubType:=wdMergeSubTypeWord
' NOTE: The actual merge is executed manually
DoCmd.RunMacro "mcrShow"
End If
It appears as if Word is not getting the correct query name, even though I CAN connect to the query from Word after the connection fails. Can anyone suggest what might have changed?