How To Call Function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MyWaterloo
    New Member
    • Dec 2007
    • 135

    How To Call Function

    I got this code form an old post on here, and I was wondering how to call this to run. What do I have to do to call/activate/run this function?


    Public Function PrintPDFemail2( )

    DoCmd.OpenRepor t "rptJobItemStat ", acViewNormal

    Dim strEmail As String
    Dim strMsg As String
    Dim oLook As Object
    Dim oMail As Object

    Set oLook = CreateObject("O utlook.Applicat ion")
    Set oMail = oLook.createite m(0)
    With oMail
    .to = "someone@email. com"
    .body = "Attached is a PDF file for your viewing"
    .Subject = "Job Item"
    .Attachments.Ad d ("C:\Documen ts and
    Settings\ron_m\ Desktop\rptJobI temStat.pdf")

    .Send

    End With

    Set oMail = Nothing
    Set oLook = Nothing
    End Function



    Thanks
  • puppydogbuddy
    Recognized Expert Top Contributor
    • May 2007
    • 1923

    #2
    A simple way is to Call the function via code activated on the click of a button on the form like this:

    Code:
    Private Sub btnEmail_Click()
    
    Call PrintPDFemail2
    
    End Sub

    Comment

    • overcomer
      New Member
      • Nov 2008
      • 25

      #3
      elow

      hi,

      calling a function in vba is simple as the name of the function itself..

      sub Proc_name()

      function_name

      end sub

      Comment

      Working...