If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Send Email from Form Problem
I have a form with a txt box (txtClientRepEmail) which holds an email
address and I have a cmd buttonwhich creates an email using outlook using the following code:- Private Sub cmdSendEmail_Click() Dim Email As String Dim ref As String Dim origin As String Dim destination As String Dim Notes As String Dim objOutlook As Outlook.Application Dim objEmail As Outlook.MailItem Email = Me!txtClientRepEmail Set objOutlook = CreateObject("Outlook.application") Set objEmail = objOutlook.CreateItem(olMailItem) With objEmail .To = Email .Display 'sends the email in Outlook. Change to DISPLAY if you want to be able to 'modify or see what you have created before sending the email End With objOutlook.Quit Set objEmail = Nothing End Sub The code breaks on the "Email = Me!txtClientRepEmail" line and I can't understand why and as a separate issue, in the message created the receipients address line is displayed as : # and not just -- Regards Andy ___________ Andy Roberts Win XP Pro Access 2007 |
#2
|
|||
|
|||
Send Email from Form Problem
Ok, I've figured whyI'm getting the error, but don't know how to fix it. The
form is a continuous form with the email field hidden. The error occurs when the cmd button at the end of a record with no email address is clicked. If there is an email address it works. 1. How do I deal with clicking thebutton when there is no email address in the field (i.e. it is blank) 2. I thought of dealing with this by hiding the the cmd button if the txt box was clear using the following code on the Form OnLoad event: Private Sub Form_Load() If Me.txtClientRepEmail = Null Then Me.cmdSendEmail.Visible = False Else Me.cmdSendEmail.Visible = True End If End Sub But this seems to achieve nothing. As a separate issue, but related, could I get a "tooltip" to appear showing the email address when Ihover over the cmd button? -- Regards Andy ___________ Andy Roberts Win XP Pro Access 2007 "Andy Roberts" wrote in message ... I have a form with a txt box (txtClientRepEmail) which holds an email address and I have a cmd buttonwhich creates an email using outlook using the following code:- Private Sub cmdSendEmail_Click() Dim Email As String Dim ref As String Dim origin As String Dim destination As String Dim Notes As String Dim objOutlook As Outlook.Application Dim objEmail As Outlook.MailItem Email = Me!txtClientRepEmail Set objOutlook = CreateObject("Outlook.application") Set objEmail = objOutlook.CreateItem(olMailItem) With objEmail .To = Email .Display 'sends the email in Outlook. Change to DISPLAY if you want to be able to 'modify or see what you have created before sending the email End With objOutlook.Quit Set objEmail = Nothing End Sub The code breaks on the "Email = Me!txtClientRepEmail" line and I can't understand why and as a separate issue, in the message created the receipients address line is displayed as : # and not just -- Regards Andy ___________ Andy Roberts Win XP Pro Access 2007 |
#3
|
|||
|
|||
Send Email from Form Problem
1) Easiest thing to do is check for the null/blank. Add this code to your On
Click event: If IsNull(Me.txtClientRepEmail) Then MsgBox("Send a nice message here") else 'send your email here 2) enter some text in the "ControlTip Text" property for the txtClientRepEmail text box. This is located under "Other" properties. "Andy Roberts" wrote: Ok, I've figured whyI'm getting the error, but don't know how to fix it. The form is a continuous form with the email field hidden. The error occurs when the cmd button at the end of a record with no email address is clicked. If there is an email address it works. 1. How do I deal with clicking thebutton when there is no email address in the field (i.e. it is blank) 2. I thought of dealing with this by hiding the the cmd button if the txt box was clear using the following code on the Form OnLoad event: Private Sub Form_Load() If Me.txtClientRepEmail = Null Then Me.cmdSendEmail.Visible = False Else Me.cmdSendEmail.Visible = True End If End Sub But this seems to achieve nothing. As a separate issue, but related, could I get a "tooltip" to appear showing the email address when Ihover over the cmd button? -- Regards Andy ___________ Andy Roberts Win XP Pro Access 2007 "Andy Roberts" wrote in message ... I have a form with a txt box (txtClientRepEmail) which holds an email address and I have a cmd buttonwhich creates an email using outlook using the following code:- Private Sub cmdSendEmail_Click() Dim Email As String Dim ref As String Dim origin As String Dim destination As String Dim Notes As String Dim objOutlook As Outlook.Application Dim objEmail As Outlook.MailItem Email = Me!txtClientRepEmail Set objOutlook = CreateObject("Outlook.application") Set objEmail = objOutlook.CreateItem(olMailItem) With objEmail .To = Email .Display 'sends the email in Outlook. Change to DISPLAY if you want to be able to 'modify or see what you have created before sending the email End With objOutlook.Quit Set objEmail = Nothing End Sub The code breaks on the "Email = Me!txtClientRepEmail" line and I can't understand why and as a separate issue, in the message created the receipients address line is displayed as : # and not just -- Regards Andy ___________ Andy Roberts Win XP Pro Access 2007 |
#4
|
|||
|
|||
Send Email from Form Problem
Thanks Chris
This works great However, the controltext suggestion just shows whatever I put in the proprty. What I want to do is show each individual email address as a control tip (i.e. each one will be different) and either show no tip or a set message if no email address exits. -- Regards Andy ___________ Andy Roberts Win XP Pro Access 2007 "Christopher Robin" wrote in message ... 1) Easiest thing to do is check for the null/blank. Add this code to your On Click event: If IsNull(Me.txtClientRepEmail) Then MsgBox("Send a nice message here") else 'send your email here 2) enter some text in the "ControlTip Text" property for the txtClientRepEmail text box. This is located under "Other" properties. "Andy Roberts" wrote: Ok, I've figured whyI'm getting the error, but don't know how to fix it. The form is a continuous form with the email field hidden. The error occurs when the cmd button at the end of a record with no email address is clicked. If there is an email address it works. 1. How do I deal with clicking thebutton when there is no email address in the field (i.e. it is blank) 2. I thought of dealing with this by hiding the the cmd button if the txt box was clear using the following code on the Form OnLoad event: Private Sub Form_Load() If Me.txtClientRepEmail = Null Then Me.cmdSendEmail.Visible = False Else Me.cmdSendEmail.Visible = True End If End Sub But this seems to achieve nothing. As a separate issue, but related, could I get a "tooltip" to appear showing the email address when Ihover over the cmd button? -- Regards Andy ___________ Andy Roberts Win XP Pro Access 2007 "Andy Roberts" wrote in message ... I have a form with a txt box (txtClientRepEmail) which holds an email address and I have a cmd buttonwhich creates an email using outlook using the following code:- Private Sub cmdSendEmail_Click() Dim Email As String Dim ref As String Dim origin As String Dim destination As String Dim Notes As String Dim objOutlook As Outlook.Application Dim objEmail As Outlook.MailItem Email = Me!txtClientRepEmail Set objOutlook = CreateObject("Outlook.application") Set objEmail = objOutlook.CreateItem(olMailItem) With objEmail .To = Email .Display 'sends the email in Outlook. Change to DISPLAY if you want to be able to 'modify or see what you have created before sending the email End With objOutlook.Quit Set objEmail = Nothing End Sub The code breaks on the "Email = Me!txtClientRepEmail" line and I can't understand why and as a separate issue, in the message created the receipients address line is displayed as : # and not just -- Regards Andy ___________ Andy Roberts Win XP Pro Access 2007 |
#5
|
|||
|
|||
Send Email from Form Problem
Apprently you can set the control tip in code.
I.E. me.txtControl.ControlTipText = "Something you want to see" so you can use the On Control event and populate it with the data in your control and format it as a hyperlink. "Andy Roberts" wrote: Thanks Chris This works great However, the controltext suggestion just shows whatever I put in the proprty. What I want to do is show each individual email address as a control tip (i.e. each one will be different) and either show no tip or a set message if no email address exits. -- Regards Andy ___________ Andy Roberts Win XP Pro Access 2007 "Christopher Robin" wrote in message ... 1) Easiest thing to do is check for the null/blank. Add this code to your On Click event: If IsNull(Me.txtClientRepEmail) Then MsgBox("Send a nice message here") else 'send your email here 2) enter some text in the "ControlTip Text" property for the txtClientRepEmail text box. This is located under "Other" properties. "Andy Roberts" wrote: Ok, I've figured whyI'm getting the error, but don't know how to fix it. The form is a continuous form with the email field hidden. The error occurs when the cmd button at the end of a record with no email address is clicked. If there is an email address it works. 1. How do I deal with clicking thebutton when there is no email address in the field (i.e. it is blank) 2. I thought of dealing with this by hiding the the cmd button if the txt box was clear using the following code on the Form OnLoad event: Private Sub Form_Load() If Me.txtClientRepEmail = Null Then Me.cmdSendEmail.Visible = False Else Me.cmdSendEmail.Visible = True End If End Sub But this seems to achieve nothing. As a separate issue, but related, could I get a "tooltip" to appear showing the email address when Ihover over the cmd button? -- Regards Andy ___________ Andy Roberts Win XP Pro Access 2007 "Andy Roberts" wrote in message ... I have a form with a txt box (txtClientRepEmail) which holds an email address and I have a cmd buttonwhich creates an email using outlook using the following code:- Private Sub cmdSendEmail_Click() Dim Email As String Dim ref As String Dim origin As String Dim destination As String Dim Notes As String Dim objOutlook As Outlook.Application Dim objEmail As Outlook.MailItem Email = Me!txtClientRepEmail Set objOutlook = CreateObject("Outlook.application") Set objEmail = objOutlook.CreateItem(olMailItem) With objEmail .To = Email .Display 'sends the email in Outlook. Change to DISPLAY if you want to be able to 'modify or see what you have created before sending the email End With objOutlook.Quit Set objEmail = Nothing End Sub The code breaks on the "Email = Me!txtClientRepEmail" line and I can't understand why and as a separate issue, in the message created the receipients address line is displayed as : # and not just -- Regards Andy ___________ Andy Roberts Win XP Pro Access 2007 |
#6
|
|||
|
|||
Send Email from Form Problem
that would be the On Current event. Can't edit my response here. =((
"Christopher Robin" wrote: Apprently you can set the control tip in code. I.E. me.txtControl.ControlTipText = "Something you want to see" so you can use the On Control event and populate it with the data in your control and format it as a hyperlink. "Andy Roberts" wrote: Thanks Chris This works great However, the controltext suggestion just shows whatever I put in the proprty. What I want to do is show each individual email address as a control tip (i.e. each one will be different) and either show no tip or a set message if no email address exits. -- Regards Andy ___________ Andy Roberts Win XP Pro Access 2007 "Christopher Robin" wrote in message ... 1) Easiest thing to do is check for the null/blank. Add this code to your On Click event: If IsNull(Me.txtClientRepEmail) Then MsgBox("Send a nice message here") else 'send your email here 2) enter some text in the "ControlTip Text" property for the txtClientRepEmail text box. This is located under "Other" properties. "Andy Roberts" wrote: Ok, I've figured whyI'm getting the error, but don't know how to fix it. The form is a continuous form with the email field hidden. The error occurs when the cmd button at the end of a record with no email address is clicked. If there is an email address it works. 1. How do I deal with clicking thebutton when there is no email address in the field (i.e. it is blank) 2. I thought of dealing with this by hiding the the cmd button if the txt box was clear using the following code on the Form OnLoad event: Private Sub Form_Load() If Me.txtClientRepEmail = Null Then Me.cmdSendEmail.Visible = False Else Me.cmdSendEmail.Visible = True End If End Sub But this seems to achieve nothing. As a separate issue, but related, could I get a "tooltip" to appear showing the email address when Ihover over the cmd button? -- Regards Andy ___________ Andy Roberts Win XP Pro Access 2007 "Andy Roberts" wrote in message ... I have a form with a txt box (txtClientRepEmail) which holds an email address and I have a cmd buttonwhich creates an email using outlook using the following code:- Private Sub cmdSendEmail_Click() Dim Email As String Dim ref As String Dim origin As String Dim destination As String Dim Notes As String Dim objOutlook As Outlook.Application Dim objEmail As Outlook.MailItem Email = Me!txtClientRepEmail Set objOutlook = CreateObject("Outlook.application") Set objEmail = objOutlook.CreateItem(olMailItem) With objEmail .To = Email .Display 'sends the email in Outlook. Change to DISPLAY if you want to be able to 'modify or see what you have created before sending the email End With objOutlook.Quit Set objEmail = Nothing End Sub The code breaks on the "Email = Me!txtClientRepEmail" line and I can't understand why and as a separate issue, in the message created the receipients address line is displayed as : # and not just -- Regards Andy ___________ Andy Roberts Win XP Pro Access 2007 |
#8
|
|||
|
|||
Send Email from Form Problem
Unfortunately, I don't have an exact answer for you. I'd try to set the Is
Hyperlink property to No, and the Display as Hyperlink doesn't seem to have anything useful for not displaying it as a hyperlink. I'd also check to see if there are any options for Me.txtClientRepEmail, like ToString or something to remove the hyperlink. "Andy Roberts" wrote: Chris Certainly getting there. This kind of helps. If I set the form OnCurrent event to... Me.cmdSendEmail.ControlTipText = Me.txtClientRepEmail ....it works to a point, however when hovering over each cmd button it only displays the email address as a control tip of the selected record. I'm also still getting it displayed as # and not just -- Regards Andy ___________ Andy Roberts Win XP Pro Access 2007 "Christopher Robin" wrote in message ... that would be the On Current event. Can't edit my response here. =(( "Christopher Robin" wrote: Apprently you can set the control tip in code. I.E. me.txtControl.ControlTipText = "Something you want to see" so you can use the On Control event and populate it with the data in your control and format it as a hyperlink. "Andy Roberts" wrote: Thanks Chris This works great However, the controltext suggestion just shows whatever I put in the proprty. What I want to do is show each individual email address as a control tip (i.e. each one will be different) and either show no tip or a set message if no email address exits. -- Regards Andy ___________ Andy Roberts Win XP Pro Access 2007 "Christopher Robin" wrote in message ... 1) Easiest thing to do is check for the null/blank. Add this code to your On Click event: If IsNull(Me.txtClientRepEmail) Then MsgBox("Send a nice message here") else 'send your email here 2) enter some text in the "ControlTip Text" property for the txtClientRepEmail text box. This is located under "Other" properties. "Andy Roberts" wrote: Ok, I've figured whyI'm getting the error, but don't know how to fix it. The form is a continuous form with the email field hidden. The error occurs when the cmd button at the end of a record with no email address is clicked. If there is an email address it works. 1. How do I deal with clicking thebutton when there is no email address in the field (i.e. it is blank) 2. I thought of dealing with this by hiding the the cmd button if the txt box was clear using the following code on the Form OnLoad event: Private Sub Form_Load() If Me.txtClientRepEmail = Null Then Me.cmdSendEmail.Visible = False Else Me.cmdSendEmail.Visible = True End If End Sub But this seems to achieve nothing. As a separate issue, but related, could I get a "tooltip" to appear showing the email address when Ihover over the cmd button? -- Regards Andy ___________ Andy Roberts Win XP Pro Access 2007 "Andy Roberts" wrote in message ... I have a form with a txt box (txtClientRepEmail) which holds an address and I have a cmd buttonwhich creates an email using outlook using the following code:- Private Sub cmdSendEmail_Click() Dim Email As String Dim ref As String Dim origin As String Dim destination As String Dim Notes As String Dim objOutlook As Outlook.Application Dim objEmail As Outlook.MailItem Email = Me!txtClientRepEmail Set objOutlook = CreateObject("Outlook.application") Set objEmail = objOutlook.CreateItem(olMailItem) With objEmail .To = Email .Display 'sends the email in Outlook. Change to DISPLAY if you want to be able to 'modify or see what you have created before sending the email End With objOutlook.Quit Set objEmail = Nothing End Sub The code breaks on the "Email = Me!txtClientRepEmail" line and I can't understand why and as a separate issue, in the message created the receipients address line is displayed as : # and not just -- Regards Andy ___________ Andy Roberts Win XP Pro Access 2007 |
Thread Tools | |
Display Modes | |
|
|