A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Send Email from Form Problem



 
 
Thread Tools Display Modes
  #1  
Old June 26th, 2008, 09:33 PM posted to microsoft.public.access.forms
Andy Roberts
external usenet poster
 
Posts: 183
Default 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  
Old June 26th, 2008, 09:43 PM posted to microsoft.public.access.forms
Andy Roberts
external usenet poster
 
Posts: 183
Default 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  
Old June 26th, 2008, 11:27 PM posted to microsoft.public.access.forms
Christopher Robin
external usenet poster
 
Posts: 42
Default 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  
Old June 26th, 2008, 11:54 PM posted to microsoft.public.access.forms
Andy Roberts
external usenet poster
 
Posts: 183
Default 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  
Old June 27th, 2008, 01:02 AM posted to microsoft.public.access.forms
Christopher Robin
external usenet poster
 
Posts: 42
Default 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  
Old June 27th, 2008, 01:05 AM posted to microsoft.public.access.forms
Christopher Robin
external usenet poster
 
Posts: 42
Default 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







  #7  
Old June 27th, 2008, 05:32 PM posted to microsoft.public.access.forms
Andy Roberts
external usenet poster
 
Posts: 183
Default Send Email from Form Problem

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
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  
Old June 27th, 2008, 08:13 PM posted to microsoft.public.access.forms
Christopher Robin
external usenet poster
 
Posts: 42
Default 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
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










 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:11 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.