Creating an appointment in outlook shared calendar using an access form (1 Viewer)

darbid

Registered User.
Local time
Today, 05:10
Joined
Jun 26, 2008
Messages
1,428
strname needs to be before objRecip
 

whybrow23

Registered User.
Local time
Today, 04:10
Joined
May 20, 2011
Messages
38
great it's working now, thanks for all your help. But I have one more thing.

For some reason it only putting something in the calendar for 12 midnight till 00:30, what will i need to do to get it to be a all day event
 

whybrow23

Registered User.
Local time
Today, 04:10
Joined
May 20, 2011
Messages
38
i've worked out the all day event. but I've noticed if i book say today and tomorrow it only show today being book, any idears?
 

darbid

Registered User.
Local time
Today, 05:10
Joined
Jun 26, 2008
Messages
1,428
great it's working now, thanks for all your help. But I have one more thing.

For some reason it only putting something in the calendar for 12 midnight till 00:30, what will i need to do to get it to be a all day event

You need to set the start and end properties of the appointment

Code:
objAppt.Start = #2/2/2003 3:00:00 PM#
    objAppt.End = #2/2/2003 4:00:00 PM#

This I have copied from MSDN right now as I am not an a PC with Office.

I do something like this to get that date time

Code:
Format(Date, shortDate) & " " & Format(Date, ShortTime)
 

whybrow23

Registered User.
Local time
Today, 04:10
Joined
May 20, 2011
Messages
38
Morning.

me again, I've had a play around with the date time code and surprise surprise I really don't get it :)

I take it I will have to replace the code I have for this you sent?

With objAppt
strName = Me.Text28
.Start = Me!AbsenceDateFrom
.End = Me!AbsenceDateTo
.Subject = Me!Subject
If Not IsNull(Me!AbsenceNotes) Then .Body = Me!AbsenceNotes
.AllDayEvent = True
.BusyStatus = olOutOfOffice

Unless I'm missing something which is very likely, my code picks up the dates from the form, how does it do it with the code you sent.
 

darbid

Registered User.
Local time
Today, 05:10
Joined
Jun 26, 2008
Messages
1,428
Unless I'm missing something which is very likely, my code picks up the dates from the form, how does it do it with the code you sent.

Code:
With objAppt
.Start =Format(Me!AbsenceDateFrom, shortDate) & " 08:00:00"
.End = Format(Me!AbsenceDateTo, shortDate) & " 09:00:00"
.Subject = Me!Subject
If Not IsNull(Me!AbsenceNotes) Then .Body = Me!AbsenceNotes
.AllDayEvent = True
.BusyStatus = olOutOfOffice
Please note the space between your date and the time.

I am assuming your control Me!AbsenceDateFrom is a proper date

Start time is your date and 8 am. End is your date and 9am
 

whybrow23

Registered User.
Local time
Today, 04:10
Joined
May 20, 2011
Messages
38
yes Me!AbsenceDateFrom is a proper date - 27/05/11

so I can change those's times to say:

Start time is my date and 00:00
End time is my date and 23:59

So then I can book say:

27/05/11 to 28/05/11 and then it would show me out for both days.

Also I would like to take this moment to say a big thank you for all your help so far.

Your the man A************
 

darbid

Registered User.
Local time
Today, 05:10
Joined
Jun 26, 2008
Messages
1,428
if there is a question in there then yes try it.

your welcome.
 

whybrow23

Registered User.
Local time
Today, 04:10
Joined
May 20, 2011
Messages
38
while we're on a roll, could I ask one more thing.

At the moment on the database I can go in to it, pick someone I have permission to book to there calendar and add an appointment. Is it also possible to have the appointment put into another shared calendar at the sametime?

So it would then go into his/hers plus shared calendar
 

darbid

Registered User.
Local time
Today, 05:10
Joined
Jun 26, 2008
Messages
1,428
while we're on a roll, could I ask one more thing.

At the moment on the database I can go in to it, pick someone I have permission to book to there calendar and add an appointment. Is it also possible to have the appointment put into another shared calendar at the sametime?

So it would then go into his/hers plus shared calendar

What you are doing is making an appointment on behalf of someone else. There can bo only one person that "makes" a calendar or email etc.

But once you have an appointment ie irrespective if it is yours or you are doing it on behalf of someone else, then you can add recipients or invite people to the appointment. These other people will receive an email invitation to the meeting which they will need to accept or reject.

Thus either create an appointment and add other people to it.

or

Create a new appointment on behalf of each person.
 

whybrow23

Registered User.
Local time
Today, 04:10
Joined
May 20, 2011
Messages
38
ok, I don't want it to send a invitation to them, I just need it to go into the persons calendar which it does already plus be put into this shared one.

So to do that could I not just copy and use my current code to run at same time so it would go into both calendars or doesn't it work like that?
 

whybrow23

Registered User.
Local time
Today, 04:10
Joined
May 20, 2011
Messages
38
Within the code for this bit

strName = Me.Email

I did tried this but it didn't like it

strName = Me.Email & ";myself@myself.co.uk"
 

whybrow23

Registered User.
Local time
Today, 04:10
Joined
May 20, 2011
Messages
38
Hi Darbid

After somemore looking around and help I'm now able to send the appointment to 2 calendars with one click.

Again many many thanks for all your help, would of not got this far without it.
 

cruzpatas

Registered User.
Local time
Yesterday, 22:10
Joined
Dec 16, 2005
Messages
41
Is there any posibility you can post your correct (working code. I have been playing wth this for a while?
 

whybrow23

Registered User.
Local time
Today, 04:10
Joined
May 20, 2011
Messages
38
Morning and of course. Let me know how you get on


Private Sub AddAppt_Click()
WriteAppoinment (Me.Email)
WriteAppoinment (Me.Mist_Email)
ClearForm
End Sub

Public Sub WriteAppoinment(ByVal AddressToWrite As String)
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder 'get name of other persons folder
Dim objRecip As Outlook.Recipient 'other persons name
Dim strName As String
Dim objAppt As Outlook.AppointmentItem
Dim objApp As Outlook.Application
Dim outobj As Outlook.Application
Set outobj = CreateObject("outlook.application")
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
'strName = Me.Email
strName = AddressToWrite
Set objRecip = objNS.CreateRecipient(strName)
If objRecip Is Nothing Then
MsgBox "You do not have a recipient"
Exit Sub
End If
If Not objRecip.Resolve Then
MsgBox "You have not given a proper email address"
Exit Sub
End If
Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderCalendar)
If Not objFolder Is Nothing Then
Set objAppt = objFolder.Items.add
Else
MsgBox "You do not have the right to view this persons calendar"
Exit Sub
End If
With objAppt
.Start = Format(Me!LeaveDateFrom, shortDate) & " 00:00:00"
.End = Format(Me!LeaveDateTo, shortDate) & " 23:59:59"
.Subject = Me!Subject
If Not IsNull(Me!LeaveNotes) Then .Body = Me!LeaveNotes
.AllDayEvent = True
.BusyStatus = olOutOfOffice

.Save

End With
DoCmd.RunCommand acCmdSaveRecord

Set objNS = Nothing
Set objFolder = Nothing
Set objRecip = Nothing
Set objApp = Nothing
Set outobj = Nothing

End Sub
 

cruzpatas

Registered User.
Local time
Yesterday, 22:10
Joined
Dec 16, 2005
Messages
41
It works great! Now to make it go to a different folder in My Calendars. :eek:
 

bsnwyase

New member
Local time
Yesterday, 20:10
Joined
Nov 26, 2012
Messages
4
Hi Darbid,

I have been following this thread and from your posts i have successfully been able to create appointments on my shared calendar by using the start date and duration to set a slot. Therefore I would like to say a big THANK YOU :).

However I have one question that has not been covered here. I wish to check the slot before adding the appointment i.e. I wish to check whether the slot is busy or free and if busy check the type of category used.

Currently i can add the appointment even though it may conflict with another appointment. I understand the thread is old but even now it has helped me.

Thanks
 

Users who are viewing this thread

Top Bottom