Can someone please look over this code?

G

Guest

Hi everyone

I've been having a problem with the code below. On most of our computers it
works fine but on three (that seem to have an ActiveX component problem) it
does everything until it gets to the create new mail item section. Any
help/comments appreciated. Thanks

Private Sub cmdEmailLynx_Click()

Me.NotificationDate = Now()
Me.AdminName.SetFocus
Me.AdminPosition.SetFocus
Me.AdminPhone.SetFocus
Me.AdminEmail.SetFocus

Dim strWhere As String
strWhere = "[CRDNumber] = " & Me.[CRDNumber]

If Me.Dirty Then
Me.Dirty = False
End If

If Me.NewRecord Then
MsgBox "Enter all information required!", vbExclamation
Else
DoCmd.OpenReport "rptLynxRequest", acViewPreview, , strWhere

Dim strSavedClaim As String
strSavedClaim = "C:\WUTemp\" & "rptLynxRequest" & ".snp"
DoCmd.OutputTo acOutputReport, , acFormatSNP, strSavedClaim, 0
DoCmd.Close
End If

DoCmd.Close acReport, "rptLynxRequest"

Dim Olk As Object
Dim OlkMsg As Object
Set Olk = CreateObject("Outlook.Application")
Set OlkMsg = Olk.CreateItem(0)

OlkMsg.To = "(e-mail address removed)"
OlkMsg.Subject = "Claim on Consignment " & Me![ConsignmentNumber]
OlkMsg.Body = "Dear Jonathan" & vbCrLf & vbCrLf & "Please find attached
a Notification for Claim form." & vbCrLf & vbCrLf & Me![AdminName] & vbCrLf &
"Metroplan Ltd"
OlkMsg.Attachments.Add strSavedClaim
OlkMsg.Display

Set Olk = Nothing
Set OlkMsg = Nothing

Kill ("C:\WUTemp\rptLynxRequest.snp")

End Sub
 
T

tlyczko

If you are receiving any error messages, please tell us.

If you are getting wrong/incorrect responses, please tell us.

One or the other of the above may help us help you.

Have you checked the PCs' Outlook settings vis-a-vis attachments??

Thank you, Tom
 
G

Guest

I'm not getting any error messages. The code runs (report comes up, snapshot
report is generated and saved) but then nothing else happens. On my PC the
next thing it does is pop up a new email complete with details to send.

I haven't specifically checked Outlook on the PCs with the problem, I've
quickly looked them over but don't see any information re attachments. What
types of things can i check?

Thanks
 
B

Bob Hairgrove

Dim Olk As Object
Dim OlkMsg As Object
Set Olk = CreateObject("Outlook.Application")
Set OlkMsg = Olk.CreateItem(0)
[snip]

Set Olk = Nothing
Set OlkMsg = Nothing

You should probably set OlkMsg to Nothing before setting Olk to
Nothing because OlkMsg is dependent on Olk.

Otherwise, check to make sure that Outlook is properly installed and
registered on the computers with the problem. Also, be sure that the
VBA reference to Outlook is not missing or broken in the database
files on the problem PCs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Email Body Coding 3

Top