View Single Post
  #1   Report Post  
Murray Muspratt-Rouse Murray Muspratt-Rouse is offline
Member
 
Location: Mill Hill, London, England
Posts: 44
Smile Connection to database fails

This is a repeat of a problem I have had solved for me before - by Peter Jamieson, back in March. The problem has recurred in another system. Here is the code: -
strCurrentFileName = CurrentDb.Name
Set objApp = CreateObject("Word.Application")
objApp.Visible = False
'objApp.Activate
'Set objMMMD = objApp.Documents.Open(FileName:=strDocName)

objApp.Documents.Open FileName:=strDocName, ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False _
, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", XMLTransform:=""

objApp.ActiveDocument.MailMerge.OpenDataSource Name:= _
"C:\MIBnew2\empty.odc", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;Password=""pixie 7826"";" & _
"User ID=Murray M-R;Date Source=" & strCurrentFileName & ";" & _
"Mode=Read;Jet OLEDB:System database=\\Dove4\MIBnew2\Security1.mdw;" _
, SQLStatement:="SELECT * FROM `mergetable`", SQLStatement1:="", _
SubType:=wdMergeSubTypeAccess

This is where the pop up appears asking for input, quoting the user name and password set in the code above. I realise that I have made a mistake somewhere, but I cannot see it for looking!

The empty.odc file was constructed by using Notepad as Peter suggested.

Murray