' Can anyone suggest what to look for to resolve this.
Dim l_Database as DAO.Database
Dim l_Query as DAO.Querydef
Dim lr_Data as DAO.Recordset
Dim ls_HTML_Body as String
On Error GoTo Errs_This_Module_Name
Set l_Database = DBEngine(0) (0)
Set l_Query = l_Database.QueryDefs("qryRptDuesExpireLetter")
l_Query.Parameters(0) = Me.txtDate ' = 30/09/2008
Set lr_Data = l_Query.OpenRecordset
If lr_Data.RecordCount = 0 Then
...
else
Do Until lr_Data.EOF
DoCmd.OutputTo acOutputReport, "rptMemberProfile", acFormatSNP, "C:\NNNNNN_Profile.snp", False
DoEvents
If Not (Send_An_Outlook_Message("Notice of Dues Expiration.", _
lr_Data!FirstName & " " & _
lr_Data!LastName & _
"[mailto:" & lr_Data!Email & "]", _
ls_HTML_Body, _
Email_For("Secretary"), _
Email_For("Treasurer"), _
"C:\NNNNNN_Invoice.doc", _
"C:\NNNNNN_Profile.snp")) Then
....
End if
...
lr_Data.MoveNext
Loop
End if
' WITHOUT the Docmd, all works fine.
' WITH the DoCmd executed but code stepped to the If Not ... statement, the references to lr_Data! Fields are "invalid or the object is no longer set".
' The DoCmd works fine as well.
' 'Yes, other queries occur in the creation of the C:\NNNNNN_Profile.snp file (Report)
Dim l_Database as DAO.Database
Dim l_Query as DAO.Querydef
Dim lr_Data as DAO.Recordset
Dim ls_HTML_Body as String
On Error GoTo Errs_This_Module_Name
Set l_Database = DBEngine(0) (0)
Set l_Query = l_Database.QueryDefs("qryRptDuesExpireLetter")
l_Query.Parameters(0) = Me.txtDate ' = 30/09/2008
Set lr_Data = l_Query.OpenRecordset
If lr_Data.RecordCount = 0 Then
...
else
Do Until lr_Data.EOF
DoCmd.OutputTo acOutputReport, "rptMemberProfile", acFormatSNP, "C:\NNNNNN_Profile.snp", False
DoEvents
If Not (Send_An_Outlook_Message("Notice of Dues Expiration.", _
lr_Data!FirstName & " " & _
lr_Data!LastName & _
"[mailto:" & lr_Data!Email & "]", _
ls_HTML_Body, _
Email_For("Secretary"), _
Email_For("Treasurer"), _
"C:\NNNNNN_Invoice.doc", _
"C:\NNNNNN_Profile.snp")) Then
....
End if
...
lr_Data.MoveNext
Loop
End if
' WITHOUT the Docmd, all works fine.
' WITH the DoCmd executed but code stepped to the If Not ... statement, the references to lr_Data! Fields are "invalid or the object is no longer set".
' The DoCmd works fine as well.
' 'Yes, other queries occur in the creation of the C:\NNNNNN_Profile.snp file (Report)
Last edited: