Hi,
Question: Access2000
I activate the code below from a form.
The code does what is aimed at.Although the particular e-mails are created the code does not finish.
A dark grey square forms itself over the form from which the code was activated. The code as can be seen closes this form but does not.It appears as if the instance of access is terminate.dSomething is missing and I am stuck.
Can any one please help
The code:
Function OutputSnapshotFile()
Dim strOutputFormat As String, strName As String, strPath As String
DoCmd.Hourglass True
strOutputFormat = "Snapshot Format"
Dim db As Database, rst As Recordset
Dim File As String, Name As String, DM As String, Ext As String
Set db = CurrentDb()
Set rst = db.OpenRecordset("LicenseeMails", dbOpenTable)
rst.MoveFirst
DM = Mid(rst![Datum], 6, 2)
Ext = DM & ".snp"
Do While Not rst.EOF
Forms![FrmMailChoice]![NO] = rst!LicenseeNo
Name = ("Rem" & rst![LicenseeNo] & Ext)
File = "C:\RptContainer\" & Name
strPath = File
strName = "ReminderNoReportsMails"
DoCmd.OutputTo acOutputReport, "ReminderNoReportsMails", acFormatSNP, strPath
'Create email
Dim Objoutlook As Outlook.Application
Dim objNewMail As Outlook.MailItem
Dim objnamespace As Outlook.NameSpace
Dim varRecip As Variant
Dim strSubject As String
Dim strMessage As String
Dim varAttach1 As Variant
Set Objoutlook = New Outlook.Application ' Application object.
Set objnamespace = Objoutlook.GetNamespace("MAPI"
' Namespace object.
Set objNewMail = Objoutlook.CreateItem(olMailItem)
varAttach1 = strPath
strSubject = "Report attachment:" & Name
strMessage = "Urgent Reminder! No Royalty Report!. Save and print it."
objNewMail.Recipients.Add rst![LicEMail]
objNewMail.Subject = strSubject
objNewMail.Body = strMessage
objNewMail.Attachments.Add varAttach1
objNewMail.Display
objNewMail.Send
rst.MoveNext
Loop
DoCmd.Hourglass False
rst.Close
DoCmd.Close acForm, "FrmMailChoice"
DoCmd.SetWarnings False
DoCmd.OpenQuery "QryUpdateRoyControlToZero"
DoCmd.OpenForm "FrmDisplay"
Set rst = Nothing
Set Objoutlook = Nothing
Set objnamespace = Nothing
Set objNewMail = Nothing
Set db = Nothing
End Function
Question: Access2000
I activate the code below from a form.
The code does what is aimed at.Although the particular e-mails are created the code does not finish.
A dark grey square forms itself over the form from which the code was activated. The code as can be seen closes this form but does not.It appears as if the instance of access is terminate.dSomething is missing and I am stuck.
Can any one please help
The code:
Function OutputSnapshotFile()
Dim strOutputFormat As String, strName As String, strPath As String
DoCmd.Hourglass True
strOutputFormat = "Snapshot Format"
Dim db As Database, rst As Recordset
Dim File As String, Name As String, DM As String, Ext As String
Set db = CurrentDb()
Set rst = db.OpenRecordset("LicenseeMails", dbOpenTable)
rst.MoveFirst
DM = Mid(rst![Datum], 6, 2)
Ext = DM & ".snp"
Do While Not rst.EOF
Forms![FrmMailChoice]![NO] = rst!LicenseeNo
Name = ("Rem" & rst![LicenseeNo] & Ext)
File = "C:\RptContainer\" & Name
strPath = File
strName = "ReminderNoReportsMails"
DoCmd.OutputTo acOutputReport, "ReminderNoReportsMails", acFormatSNP, strPath
'Create email
Dim Objoutlook As Outlook.Application
Dim objNewMail As Outlook.MailItem
Dim objnamespace As Outlook.NameSpace
Dim varRecip As Variant
Dim strSubject As String
Dim strMessage As String
Dim varAttach1 As Variant
Set Objoutlook = New Outlook.Application ' Application object.
Set objnamespace = Objoutlook.GetNamespace("MAPI"
Set objNewMail = Objoutlook.CreateItem(olMailItem)
varAttach1 = strPath
strSubject = "Report attachment:" & Name
strMessage = "Urgent Reminder! No Royalty Report!. Save and print it."
objNewMail.Recipients.Add rst![LicEMail]
objNewMail.Subject = strSubject
objNewMail.Body = strMessage
objNewMail.Attachments.Add varAttach1
objNewMail.Display
objNewMail.Send
rst.MoveNext
Loop
DoCmd.Hourglass False
rst.Close
DoCmd.Close acForm, "FrmMailChoice"
DoCmd.SetWarnings False
DoCmd.OpenQuery "QryUpdateRoyControlToZero"
DoCmd.OpenForm "FrmDisplay"
Set rst = Nothing
Set Objoutlook = Nothing
Set objnamespace = Nothing
Set objNewMail = Nothing
Set db = Nothing
End Function