philwalker531
Registered User.
- Local time
- Today, 15:47
- Joined
- Feb 14, 2010
- Messages
- 22
Thanks for looking at this and i hope someone can help.
I have a fairly basic database using one table - from a main form i can create an appointment in outlook using event date and event time and unique ref number. ( i got the code from this site as i have no programming experience to speak of!)
the appointment creating works perfectly however i have now found that when i need to change details on the database i need to reflect the changes in outlook calendar. i was hoping using someones code i could delete the original appointment and replace it with the new edited/amended one. is this possible?
i have tried several examples from the internet but none seem to work with what i have already and i do not know enough ( anything!) to change the examples to make it work with my database.
here is the code i used for the appointment creator if this means anything!? thanks
Private Sub btnAddApptToOutlook_Click()
' Save the Current Record
If Me.Dirty Then
Me.Dirty = False
End If
' Exit the procedure if appointment has been added to Outlook.
If Me.chkaddedtooutlook = True Then
MsgBox "This appointment has already added to Microsoft Outlook.", vbCritical
Exit Sub
Else
' Add a new appointment.
' Use late binding to avoid the "Reference" issue
Dim olApp As Object 'Outlook.Application
Dim olappt As Object 'olAppointmentItem
' This is how we would do it if we were using "early binding":
' Dim outobj As Outlook.Application
' Dim outappt As Outlook.AppointmentItem
' Set outobj = CreateObject("Outlook.Application")
' Set outappt = outobj.CreateItem(olAppointmentItem)
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
' Create the New Appointment Item
Set olappt = olApp.createitem(1) ' olAppointmentItem = 1
' Add the Form data to the Appointment Properties
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.Event_date, "") & " " & Nz(Me.Event_time, "")
.duration = Nz(180, 0)
' vbNullString uses a little less memory than ""
.subject = Nz(Me.Venue, "vbnullstring") & " suite " & Nz(Me.Suite, vbNullString) & " REF " & Nz(Me.Reference, vbNullString) & " " & Nz(Me.Bride, vbNullString)
.body = Nz(Me.Chair_covers, vbNullString) & " " & Nz(Me.Description, vbNullString) & " --------(table linen)-------- " & Nz(Me.Description_2, vbNullString) & " --------- Additional Items ----------- " & Nz(Me.Description3, vbNullString) & " other info " & Nz(Me.Other_inf, vbNullString) & " address " & Nz(Me.Address_line1, vbNullString) & " " & Nz(Me.Address_line2, vbNullString) & " " & Nz(Me.Town, vbNullString) & " " & Nz(Me.Postcode, vbNullString) & " tel nos " & Nz(Me.Tel_no, vbNullString) & " " & Nz(Me.Alt_tel_no, vbNullString)
.Location = Nz(Me.Venue, vbNullString) & " " & Nz(Me.Suite, vbNullString)
' Save the Appointment Item Properties
.Save
End With
End If
' Release the Outlook object variables.
Set olappt = Nothing
Set olApp = Nothing
' Set chkAddedToOutlook to checked
Me.chkaddedtooutlook = 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
End Sub
I have a fairly basic database using one table - from a main form i can create an appointment in outlook using event date and event time and unique ref number. ( i got the code from this site as i have no programming experience to speak of!)
the appointment creating works perfectly however i have now found that when i need to change details on the database i need to reflect the changes in outlook calendar. i was hoping using someones code i could delete the original appointment and replace it with the new edited/amended one. is this possible?
i have tried several examples from the internet but none seem to work with what i have already and i do not know enough ( anything!) to change the examples to make it work with my database.
here is the code i used for the appointment creator if this means anything!? thanks
Private Sub btnAddApptToOutlook_Click()
' Save the Current Record
If Me.Dirty Then
Me.Dirty = False
End If
' Exit the procedure if appointment has been added to Outlook.
If Me.chkaddedtooutlook = True Then
MsgBox "This appointment has already added to Microsoft Outlook.", vbCritical
Exit Sub
Else
' Add a new appointment.
' Use late binding to avoid the "Reference" issue
Dim olApp As Object 'Outlook.Application
Dim olappt As Object 'olAppointmentItem
' This is how we would do it if we were using "early binding":
' Dim outobj As Outlook.Application
' Dim outappt As Outlook.AppointmentItem
' Set outobj = CreateObject("Outlook.Application")
' Set outappt = outobj.CreateItem(olAppointmentItem)
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
' Create the New Appointment Item
Set olappt = olApp.createitem(1) ' olAppointmentItem = 1
' Add the Form data to the Appointment Properties
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.Event_date, "") & " " & Nz(Me.Event_time, "")
.duration = Nz(180, 0)
' vbNullString uses a little less memory than ""
.subject = Nz(Me.Venue, "vbnullstring") & " suite " & Nz(Me.Suite, vbNullString) & " REF " & Nz(Me.Reference, vbNullString) & " " & Nz(Me.Bride, vbNullString)
.body = Nz(Me.Chair_covers, vbNullString) & " " & Nz(Me.Description, vbNullString) & " --------(table linen)-------- " & Nz(Me.Description_2, vbNullString) & " --------- Additional Items ----------- " & Nz(Me.Description3, vbNullString) & " other info " & Nz(Me.Other_inf, vbNullString) & " address " & Nz(Me.Address_line1, vbNullString) & " " & Nz(Me.Address_line2, vbNullString) & " " & Nz(Me.Town, vbNullString) & " " & Nz(Me.Postcode, vbNullString) & " tel nos " & Nz(Me.Tel_no, vbNullString) & " " & Nz(Me.Alt_tel_no, vbNullString)
.Location = Nz(Me.Venue, vbNullString) & " " & Nz(Me.Suite, vbNullString)
' Save the Appointment Item Properties
.Save
End With
End If
' Release the Outlook object variables.
Set olappt = Nothing
Set olApp = Nothing
' Set chkAddedToOutlook to checked
Me.chkaddedtooutlook = 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
End Sub
Last edited: