Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile Error: Method or Data Member Not Found

Status
Not open for further replies.

greeneyerat

Technical User
Oct 15, 2003
26
0
0
US
Hi,

I have a command button that when clicked I want to be able to send an eamil. Following is the code I have for the "on click" event procedure:

Private Sub email_Click()
Dim myOlApp As Object
Dim myEmail As Outlook.MailItem

Set myOlApp = CreateObject("Outlook.Application")
Set myEmail = myOlApp.CreateItem(olMailItem)

With myEmail
.To = Me.emailAddress
.Subject = "This is an email"
.Body = "Type email here"
End With
myEmail.Display
End Sub

The error stated in the subject line is what is being returned. I have the MS Outlook Object Library already referenced.


Second question: I have created 4 forms, and used several of the same fields from one table. Each form must remain as a stand alone form.

The problem is that when I enter a record on one form, the data also appears on the three other forms created. The forms I am using are to store data regarding written procedure for 4 departments. As a test I tried recreating one of the forms using a query and the form is visible in Design view, but not in form view.

Any help will be greatly appreciated.

Thank you!!!!


 
Hi, your email code looks correct. I would look at me.emailaddress though. If the name of the control is the same as the control then that might pose a problem. Try changing the name to txtEmailAddress.

.To = Me.txtEmailAddress

The form question...I am not clear on what it is you wish to do. You might look at creating one form and using a filter to display data pertinent to department using the form. Might avoid some duplication that way.

Hope that helps.



 
Which line of code is highlighted when you press the debug button of the error messagebox ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PHV,

The line that is highlighted when I try to Debug is:

.To = Me.EmailAddress

I tried .To = Me.txtEmailAddress and I am still getting an error.

In essence when I click the email command button all I want is the capability to send an email via MS Outlook.

Thanks for you help,
JCM
 
Does the form containing the email button has a control named EmailAddress (or txtEmailAddress) ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Yes,

the form has a filed with a control source EmailAddress.
 
What is the name of the control ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Under the Control Source property, the name is "EmailAddress
 
Not the control source but the name of the TextBox

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi,

Yes, the name and control source is "EmailAddress". I am getting "Run-time error '94':

Invalid Use of Null.

Thanks for help!
 
And which line highlighted ?
You have to enforce some validation rules before creating the mail object ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Following is the line highlighted:

.To = Me.EmailAddress

 
Private Sub email_Click()
Dim myOlApp As Object
Dim myEmail As Outlook.MailItem
If Trim(Me!emailAddress & "") = "" Then
MsgBox "No Mail Address - ABORTED"
Exit Sub
End If
Set myOlApp = CreateObject("Outlook.Application")
Set myEmail = myOlApp.CreateItem(olMailItem)

With myEmail
.To = Me.emailAddress
.Subject = "This is an email"
.Body = "Type email here"
End With
myEmail.Display
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top