Results 1 to 10 of 10
  1. #1
    Goli1984 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2011
    Posts
    9

    Post help getting access records to outlook

    Hi, I'm a novice when it comes to access programming and have so far edited some existing code to try and send my outlook records to the outlook diary. I'm not entirely sure if I did it correct, but after working around issues with IF blocks, I still have a 438 runtime error. Would be greatful if someone could look at my code and find my schoolboy errors.

    In general it works with a push button and a check box to show if the record has already been added. There is a custom function that finds if outlook is open.

    Thanks in advance.

    Private Sub Send_diary_Click()
    If Me.Dirty Then
    Me.Dirty = False
    End If

    If Me.AddedToOutlook = True Then
    MsgBox "This appointment has already added to Microsoft Outlook", vbCritical
    ' Exit the procedure
    Exit Sub
    Else

    ' Use late binding to avoid the "Reference" issue
    Dim olapp As Object ' Outlook.Application
    Dim olappt As Object ' olAppointmentItem

    End If

    If isAppThere("Outlook.Application") = False Then
    ' Outlook is not open, create a new instance
    Set olapp = CreateObject("Outlook.Application")
    Else
    ' Outlook is already open--use this method
    Set olapp = GetObject(, "Outlook.Application")
    End If
    Set olappt = olapp.CreateItem(1) ' olAppointmentItem
    With olappt
    ' If There is no Start Date or Time on
    ' the Form use Nz to avoid an error
    ' Set the Start Property Value
    .Start = Nz(Me.Start_Date, "")



    ' Set the End Property Value
    .End = Nz(Me.Expiry_Date, "")

    .Save
    End With ' Release the Outlook object variables.
    Set olappt = Nothing
    Set olapp = Nothing ' Set chkAddedToOutlook to checked
    Me.AddedToOutlook = True
    ' Save the Current Record because we checked chkAddedToOutlook
    If Me.Dirty Then
    Me.Dirty = False
    End If
    ' Inform the user
    MsgBox "Appointment Added!", vbInformation

    On Error GoTo Send_diary_Click_Err
    On Error Resume Next
    DoCmd.GoToControl Screen.PreviousControl.Name
    Err.Clear
    DoCmd.RunCommand acCmdFind
    If (MacroError <> 0) Then
    Beep
    MsgBox MacroError.Description, vbOKOnly, ""
    End If

    Send_diary_Click_Exit:
    ' Exit Function
    Send_diary_Click_Err:
    MsgBox Error$
    Resume Send_diary_Click_Exit



    End Sub
    Function isAppThere(appName) As Boolean
    On Error Resume Next
    Dim objApp As Object

    isAppThere = True
    Set objApp = GetObject(, appName)
    If Err.Number <> 0 Then isAppThere = False
    End Function

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    What's a 438 error? What line throws it? You may need to comment out the On Error lines temporarily.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Goli1984 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2011
    Posts
    9
    "If Me.AddedToOutlook = True Then" is highlighted in yellow when I debug. The error message says "object doesn't support this property or method".

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    What is AddedToOutlook? Presuming it's a control on the form, is it a yes/no field?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Goli1984 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2011
    Posts
    9
    as i said,the code is modified from an existing example. However, i do believe that line relates to a check box on my form, which fills in if the entry has been saved to Outlook.

    Thanks

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Goli1984 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2011
    Posts
    9
    With Thanks

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    There is no field in the table with that name (or anything similar). The checkbox with that label isn't bound to anything. AddedToOutlook is just a label, which you can't set a value on. The checkbox is named Check57.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Goli1984 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2011
    Posts
    9
    ok, i removed the code relating to that as it wasn't needed. The error has gone now.

    Thanks

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    No problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Assigning Outlook task from shared Outlook mailbox
    By Remster in forum Programming
    Replies: 2
    Last Post: 11-16-2011, 04:38 AM
  2. Pulling from Access into Outlook
    By erynn in forum Import/Export Data
    Replies: 1
    Last Post: 08-30-2011, 01:44 AM
  3. Access and Outlook Tasks HELP!
    By marciehen in forum Access
    Replies: 2
    Last Post: 05-20-2011, 02:41 PM
  4. Outlook to Access
    By Aubreylc in forum Import/Export Data
    Replies: 1
    Last Post: 01-25-2010, 09:37 AM
  5. MS-Access into Outlook - possible?
    By techexpressinc in forum Access
    Replies: 0
    Last Post: 01-09-2009, 01:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums