Access to outlook 2007 calendar (code mod) (1 Viewer)

robyholmes

Registered User.
Local time
Today, 20:30
Joined
Mar 2, 2009
Messages
57
Outlook calendar delete all apointments

<Please see below as this thread has changed a bit>

Hi,

I found this VBA code for adding appointments to outlooks calendar. It asks for the start date, but I would like end date (Like in outlook) not duration. Is this possible or do I just convert it to duration.

Background:
It is to be used for a holiday cottages booking system (I have posted before for a subform add and update code, working on that now). But basicly my parents, want to view the bookings on a calendar, and outlook has a very nice interface. My dad also wants to use a blackberry to snyc with outlook and get the calendar so he can view it out and about.

We have 3 cottages, so we can have 3 bookings on the same day. I could use catorgorise or 3 seperate calendars (I don't know if blackberry can support more than 1)

Task:
So i was wanting to use this code to add them to the calendar. Does this code add them, so if it was run again it would add it again, not update one that is already in?

I am using access 2007 and outlook 2007. If you want the table sturture I can post it. I would like the code, but if you have a idea about how to do it, then post and we will see which is the best solution.

Code:
'---------------------------------------------------------------------------------------
' Procedure : AppointmentsFromTable
' Author    : Darth Vodka
' Date      : 26/02/08
' Purpose   : to convert a table of appointments into outlook appointments
'---------------------------------------------------------------------------------------
'
Public Sub AppointmentsFromTable()
    Dim db              As DAO.Database
    Dim rs              As DAO.Recordset
    Dim OutObj          As Outlook.Application
    Dim OutAppt         As Outlook.AppointmentItem

    Set db = CurrentDb
    Set rs = db.OpenRecordset("tbl_Outlook_Appointments")
    
    Do Until rs.EOF
        If rs("AddedToOutlook") = False Then
            Set OutObj = CreateObject("outlook.application")
            Set OutAppt = OutObj.CreateItem(olAppointmentItem)
            With OutAppt
                .Start = rs("ApptTime")
                .Duration = rs("ApptLength")
                .Subject = rs("Appt")
                .Body = Nz(rs("ApptNotes"), "")
                .Location = Nz(rs("ApptLocation"), "")
                If rs("ApptReminder") Then
                    .ReminderMinutesBeforeStart = Nz(rs("ApptLocation"), 15)
                    .ReminderSet = True
                End If
                .Save
                rs.Edit
                rs("AddedToOutlook") = True
                rs.Update
            End With
            Set OutObj = Nothing
            Set OutAppt = Nothing
        End If
        rs.MoveNext
    Loop
    
    rs.Close
    Set db = Nothing
    Set rs = Nothing

End Sub
Thanks a lot
Rob Holmes
 
Last edited:

robyholmes

Registered User.
Local time
Today, 20:30
Joined
Mar 2, 2009
Messages
57
No help with this one? I will have to give it a try and see what I can get working on it.
 

robyholmes

Registered User.
Local time
Today, 20:30
Joined
Mar 2, 2009
Messages
57
Ok, I have made a 'Make Table Query' to produce the Appointment table. The code that is pasted above was changed to a user to update the calendar without the need for a form. He combined the date and time, but doesn't detail how.

Here is the link to the original thread

Can you help me understand how he combined them? Then I can try it. Thanks
 

robyholmes

Registered User.
Local time
Today, 20:30
Joined
Mar 2, 2009
Messages
57
I'VE DONE IT!

WOOOOOT! Dude I'm happy now. I am just going to change the code a little and I will post it back.

Now this is all well and good if they don't change in the database, how could I update them. It might be a bit hard, would it be easier to delete the calendar and import them all again? Seems a lot of proccessing but it did all my bookings in no time at all. I would just like it to stay up to date?

So does anyone know a code of deleting a calendar?

Also, how could I set a category? So if cottage_name = Sawmill it will be category Sawmill?

THANKS!
 

Users who are viewing this thread

Top Bottom