I am trying to run a query with this code;
strSQL = "SELECT * FROM qrysignin WHERE name=" & Chr(39) & me.lastname & Chr(39)
Set wrdDoc = wrdApp.Documents.open("C:My DocumentsAccesstemplatese-mailappointmentReminder.doc")
With wrdDoc.MailMerge
.OpenDataSource _
Name:="", _
LinkToSource:=True, _
Connection:="DSN=MS Access Database;DBQ=" & CurrentDb.Name, _
SQLStatement:=strSQL, _
SubType:=8 ' = wdMergeSubTypeWord2000
.SuppressBlankLines = True
End With
The query SQL is:
SELECT Contacts.First, Contacts.Name, Contacts.[e-mail], tblAppointments.ApptDate, tblAppointments.ApptTime
FROM (Contacts LEFT JOIN Patients ON Contacts.Name = Patients.Name) LEFT JOIN (Visit LEFT JOIN tblAppointments ON Visit.VisitID = tblAppointments.VisitID) ON Patients.PatientID = Visit.PatientID
WHERE (((Contacts.Name)=[forms]![contacts]![lastname]))
ORDER BY Contacts.Name
WITH OWNERACCESS OPTION;
I believe the problem lies with strSQL = "SELECT * FROM qrysignin WHERE name=" & Chr(39) & me.lastname & Chr(39) but I can't find the problem.
Does anyone see the mistake?
nebbia



