Doing nothing - no error message even!

G

Guest

I have two buttons on my form (frmFirst). One to email the details entered on
the form to a set address(cmdCustomerCare) and another to email the details
to the email address entered(cmdEmailResp). Now -I have set them up exactly
the same and the first one(cmdCustomerCare) is working beautifully but the
second one produces nothing. No email, no flickers, no error message. Why?
When they are practically the same? (posted below)

Private Sub cmdCustomerCare_Click()
On Error GoTo Err_cmdCustomerCare_Click

Dim Olk As Outlook.Application
Set Olk = CreateObject("Outlook.Application")

Dim OlkMsg As Outlook.MailItem
Set OlkMsg = Olk.CreateItem(olMailItem)

With OlkMsg

Dim OlkRecip As Outlook.Recipient
Set OlkRecip = .Recipients.Add("(e-mail address removed)")

OlkRecip.Type = olTo
.Subject = "Customer Care Follow Up CRD" & Me![pkCRDNumber]
.Send

End With

Set Olk = Nothing
Set OlkMsg = Nothing
Set OlkRecip = Nothing

Exit_cmdCustomerCare_Click:
Exit Sub

Err_cmdCustomerCare_Click:
MsgBox Err.Description
Resume Exit_cmdCustomerCare_Click

End Sub

****************************

Private Sub cmdEmailResp_Click()
On Error GoTo Err_cmdEmailResp_Click

Dim Olk As Outlook.Application
Set Olk = CreateObject("Outlook.Application")

Dim OlkMsg As Outlook.MailItem
Set OlkMsg = Olk.CreateItem(olMailItem)

With OlkMsg
.To = "mailto:" & Me![RespPersonEmail]
.Subject = "Message - Query to follow up"
.Body = "Please follow up on " & Me![pkCRDNumber]
.Send
End With

Set Olk = Nothing
Set OlkMsg = Nothing

Exit_cmdEmailResp_Click:
Exit Sub

Err_cmdEmailResp_Click:
MsgBox Err.Description
Resume Exit_cmdEmailResp_Click

End Sub

*****************************
 
G

Guest

Did you simply pen the subroutine w/o going through the button's properties,
OnClick event, Code Builder? When I don't go this way, I find the subroutine
is disconnected from the button.

In other words, if I write a subroutine and name it mybutton_Click the
subroutine is never connected with the button - unless I use the properties
window to get there.

I hope this makes sense.
 
G

Guest

No, I wrote the code into VB using the Code Builder. I go through
Properties, On Click Event then click the little … button and write the code
there.

David Mueller said:
Did you simply pen the subroutine w/o going through the button's properties,
OnClick event, Code Builder? When I don't go this way, I find the subroutine
is disconnected from the button.

In other words, if I write a subroutine and name it mybutton_Click the
subroutine is never connected with the button - unless I use the properties
window to get there.

I hope this makes sense.

albycindy said:
I have two buttons on my form (frmFirst). One to email the details entered on
the form to a set address(cmdCustomerCare) and another to email the details
to the email address entered(cmdEmailResp). Now -I have set them up exactly
the same and the first one(cmdCustomerCare) is working beautifully but the
second one produces nothing. No email, no flickers, no error message. Why?
When they are practically the same? (posted below)

Private Sub cmdCustomerCare_Click()
On Error GoTo Err_cmdCustomerCare_Click

Dim Olk As Outlook.Application
Set Olk = CreateObject("Outlook.Application")

Dim OlkMsg As Outlook.MailItem
Set OlkMsg = Olk.CreateItem(olMailItem)

With OlkMsg

Dim OlkRecip As Outlook.Recipient
Set OlkRecip = .Recipients.Add("(e-mail address removed)")

OlkRecip.Type = olTo
.Subject = "Customer Care Follow Up CRD" & Me![pkCRDNumber]
.Send

End With

Set Olk = Nothing
Set OlkMsg = Nothing
Set OlkRecip = Nothing

Exit_cmdCustomerCare_Click:
Exit Sub

Err_cmdCustomerCare_Click:
MsgBox Err.Description
Resume Exit_cmdCustomerCare_Click

End Sub

****************************

Private Sub cmdEmailResp_Click()
On Error GoTo Err_cmdEmailResp_Click

Dim Olk As Outlook.Application
Set Olk = CreateObject("Outlook.Application")

Dim OlkMsg As Outlook.MailItem
Set OlkMsg = Olk.CreateItem(olMailItem)

With OlkMsg
.To = "mailto:" & Me![RespPersonEmail]
.Subject = "Message - Query to follow up"
.Body = "Please follow up on " & Me![pkCRDNumber]
.Send
End With

Set Olk = Nothing
Set OlkMsg = Nothing

Exit_cmdEmailResp_Click:
Exit Sub

Err_cmdEmailResp_Click:
MsgBox Err.Description
Resume Exit_cmdEmailResp_Click

End Sub

*****************************
 
G

Guest

Try putting a break point on the first line of the subroutine. At least
you'd know if the subroutine was even executing.

Then, step through with F8 to find the offending code.
 

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

Top