R
Rengade
Hi all
I am trying to add a number of appoitments into outlook via access table and
using the below code
----------------
Dim MyDB As Database
Dim MyRS As Recordset
Dim objOutlook As Outlook.Application
Dim outobj As Outlook.Application
Dim outappt As Outlook.AppointmentItem
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset("tblApptExport")
MyRS.MoveFirst
Set outobj = CreateObject("outlook.application")
Set outappt = outobj.CreateItem(olAppointmentItem)
Do Until MyRS.EOF
' Save record first to be sure required fields are filled
DoCmd.RunCommand acCmdSaveRecord
' Exit the procedure if appointment has been added to Outlook.
With outappt
.Subject = Me!ApptSubject
.Start = Me!ApptDate & " " & Me!ApptStartTime
.End = Me!ApptDate & " " & Me!ApptEndTime
.location = Me!ApptLocation
.ReminderSet = False
.Save
MyRS.MoveNext
End With
Loop
MsgBox "Appointments Added!"
Exit Sub
AddAppt_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub
End Sub
----------------------------
The loop doesn't seem to work as I only get the first record exported into
outlook
Please help
I am trying to add a number of appoitments into outlook via access table and
using the below code
----------------
Dim MyDB As Database
Dim MyRS As Recordset
Dim objOutlook As Outlook.Application
Dim outobj As Outlook.Application
Dim outappt As Outlook.AppointmentItem
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset("tblApptExport")
MyRS.MoveFirst
Set outobj = CreateObject("outlook.application")
Set outappt = outobj.CreateItem(olAppointmentItem)
Do Until MyRS.EOF
' Save record first to be sure required fields are filled
DoCmd.RunCommand acCmdSaveRecord
' Exit the procedure if appointment has been added to Outlook.
With outappt
.Subject = Me!ApptSubject
.Start = Me!ApptDate & " " & Me!ApptStartTime
.End = Me!ApptDate & " " & Me!ApptEndTime
.location = Me!ApptLocation
.ReminderSet = False
.Save
MyRS.MoveNext
End With
Loop
MsgBox "Appointments Added!"
Exit Sub
AddAppt_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub
End Sub
----------------------------
The loop doesn't seem to work as I only get the first record exported into
outlook
Please help