Results 1 to 3 of 3
  1. #1
    wfchancellor is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Posts
    1

    Forms

    I would like to clear a form after I have posted an appointment to Outlook. The way it is now, after the appointment is sent to Outlook, the data fields stay polulated and I cannot save another appoinment in that record. I patched this code from other forums.
    code
    Private Sub cmdAddAppt_Click()
    On Error GoTo Add_Err
    'Save record first to be sure required fields are filled.
    DoCmd.RunCommand acCmdSaveRecord
    'Exit the procedure if appointment has been added to Outlook.
    If Me!AddedtoOutlook = True Then
    MsgBox "This appointment was already added to Microsoft Outlook"
    Exit Sub
    'Add a new appointment.
    Else


    Dim objOutlook As Outlook.Application
    Dim objAppt As Outlook.AppointmentItem
    Dim objRecurPattern As Outlook.RecurrencePattern
    Set objOutlook = CreateObject("Outlook.Application")
    Set objAppt = objOutlook.CreateItem(olAppointmentItem)
    With objAppt
    .Start = Me!ApptDate & " " & Me!ApptTime
    .Duration = Me!ApptLength
    .Subject = Me!Appt
    If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
    If Not IsNull(Me!ApptLocation) Then .Location = Me!ApptLocation
    If Me!ApptReminder Then
    .ReminderMinutesBeforeStart = Me!ReminderMinutes
    .ReminderSet = True
    End If
    .Save
    .Close (olSave)
    End With
    'Release the AppointmentItem object variable.
    Set objAppt = Nothing
    End If
    'Release the Outlook object variable.
    Set objOutlook = Nothing
    'Set the AddedToOutlook flag, save the record, display a message.
    Me!AddedtoOutlook = True
    DoCmd.RunCommand acCmdSaveRecord
    MsgBox "Appointment Added!"
    Exit Sub
    Add_Err:
    MsgBox "Error " & Err.Number & vbCrLf & Err.Description
    Exit Sub
    End Sub

    my code

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Why would you 'clear' the form? Is this form bound to table? Are you saving record to table? Maybe you just need to move to new record row?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    The line

    DoCmd.RunCommand acCmdSaveRecord

    indicates that the Form is, in fact, Bound to a Table/Query. That being so, you don't want to

    'save another appoinment in that record'

    but rather need a New Record, as June7 suggested. That can be done with the line of code

    DoCmd.GoToRecord , , acNewRec

    Linq ;0)>

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

Similar Threads

  1. Replies: 3
    Last Post: 10-23-2013, 08:11 AM
  2. Replies: 5
    Last Post: 01-16-2013, 03:48 PM
  3. Multiple forms or embedded sub-forms
    By Juicejam in forum Forms
    Replies: 2
    Last Post: 08-23-2011, 07:31 AM
  4. Replies: 1
    Last Post: 01-04-2011, 05:04 AM
  5. Replies: 4
    Last Post: 04-01-2009, 08:49 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