Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / November 2006

Tip: Looking for answers? Try searching our database.

Can't get this to work

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Freehal04 - 28 Nov 2006 17:14 GMT
Okay, here is the code I'm using.  I had it working but for some reason now
all I get is an error message stating Compile error, user difined type not
defined.  Before I was getting a different error.  What's wrong?

Option Compare Database

Private Sub Detail_Click()
Option Explicit

Sub sbSendMessage(Optional AttachmentPath)
  Dim objOutlook As Outlook.Application
  Dim objOutlookMsg As Outlook.MailItem
  Dim objOutlookRecip As Outlook.Recipient
  Dim objOutlookAttach As Outlook.Attachment

    ' Create the Outlook session.
  Set objOutlook = CreateObject("Outlook.Application")
  ' Create the message.
  Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
  With objOutlookMsg
     ' Add the To recipient(s) to the message. Substitute
     ' your names here.
    Set objOutlookRecip = .Recipients.Add("Douglas Clark")
     objOutlookRecip.Type = olTo
     ' Add the CC recipient(s) to the message.
     Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
     objOutlookRecip.Type = olCC
     ' Set the Subject, Body, and Importance of the message.
     .Subject = "This is a CDRL 10 day alert"
     .Body = "You have a CDRL report due in 10 days.  Please submit proper
documentation." & vbCrLf & vbCrLf
     .Importance = olImportanceHigh  'High importance
     ' Add attachments to the message.
     If Not IsMissing(AttachmentPath) Then
        Set objOutlookAttach = .Attachments.Add(AttachmentPath)
     End If
     ' Resolve each Recipient's name.
     For Each objOutlookRecip In .Recipients
        If Not objOutlookRecip.Resolve Then
           objOutlookMsg.Display

     End If
     Next
     .Send
  End With
  Set objOutlookMsg = Nothing
  Set objOutlook = Nothing
  Set objOutlookRecip = Nothing
  Set objOutlookAttach = Nothing
 
End Sub
Douglas J. Steele - 28 Nov 2006 17:22 GMT
What line of code generates the Compile error?

If it's the declarations at the top of the routine, have you set a reference
to Outlook (under Tools | References in the VB Editor)?

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Okay, here is the code I'm using.  I had it working but for some reason
> now
[quoted text clipped - 48 lines]
>
> End Sub
Freehal04 - 28 Nov 2006 17:38 GMT
I've set the reference to to Outlook, but when it won't tell me which line
has the problem.  I don't know why it won't tell me which line is messed up,
it usually does, but for some reason it won't on this one.

> What line of code generates the Compile error?
>
[quoted text clipped - 53 lines]
> >
> > End Sub
Douglas J. Steele - 28 Nov 2006 17:58 GMT
Do a Compile on your application. (It's under the Debug menu while you're in
the Editor)

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> I've set the reference to to Outlook, but when it won't tell me which line
> has the problem.  I don't know why it won't tell me which line is messed
[quoted text clipped - 61 lines]
>> >
>> > End Sub
Freehal04 - 28 Nov 2006 18:12 GMT
Okay, I did that and it said the compile error is 'Invalid inside procedure'
and it's highlighting the Option Explicit line of my code.

> Do a Compile on your application. (It's under the Debug menu while you're in
> the Editor)
[quoted text clipped - 64 lines]
> >> >
> >> > End Sub
Douglas J. Steele - 28 Nov 2006 18:36 GMT
I didn't even notice that!

Move that line to the beginning of the file, either just before or just
after Option Compare Database (it shouldn't matter which)

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Okay, I did that and it said the compile error is 'Invalid inside
> procedure'
[quoted text clipped - 73 lines]
>> >> >
>> >> > End Sub
JimB - 28 Nov 2006 18:54 GMT
You never ended your Detail_Click() subroutine.  Maybe you accidentally
deleted the end sub statement.  Your trying to start a new subroutine before
ending the other one.

Jim B.

> Okay, I did that and it said the compile error is 'Invalid inside procedure'
> and it's highlighting the Option Explicit line of my code.
[quoted text clipped - 67 lines]
> > >> >
> > >> > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.