Senniger1
asked on
Export from MS Access to Outlook Calendar
I have Office 2010. In Access 2010 I have an access form named TimeOff. I have a command button on this form that when clicked should determine which records have a check in the "Exported" field and then add each record to my Outlook 2010 Calendar.
The code I'm using (see below) are snippets I found and modified. It doesn't exactly work, but is close.
Can anyone help me with this.
Dim outobj As Outlook.Application
Dim outappt As Outlook.AppointmentItem
Dim dbsCalendarTEST As DAO.Database
Dim rstTimeOff As DAO.Recordset
Dim strSQL As String
Dim intI As Integer
On Error GoTo ErrorHandler
Set CalendarTEST = CurrentDb
strSQL = "SELECT * FROM TimeOff WHERE Exported = true"
Set rstTimeOff = CalendarTEST.OpenRecordset (strSQL, dbOpenDynaset)
DoCmd.GoToRecord , , acFirst
Set outobj = CreateObject("outlook.appl ication")
Set outappt = outobj.CreateItem(olAppoin tmentItem)
intI = 1
With rstTimeOff
Do Until .EOF
.Edit
Set outobj = CreateObject("outlook.appl ication")
Set outappt = outobj.CreateItem(olAppoin tmentItem)
With outappt
.Start = Me!DateOff
.Subject = Me!EmpInit
.Body = Me!Comments
.Save
End With
.Update
.MoveNext
intI = intI + 1
Loop
End With
rstTimeOff.Close
dbsCalendarTEST.Close
Set rstTimeOff = Nothing
Set dbsCalendarTEST = Nothing
Exit Sub
ErrorHandler:
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
Thanks in advance!
The code I'm using (see below) are snippets I found and modified. It doesn't exactly work, but is close.
Can anyone help me with this.
Dim outobj As Outlook.Application
Dim outappt As Outlook.AppointmentItem
Dim dbsCalendarTEST As DAO.Database
Dim rstTimeOff As DAO.Recordset
Dim strSQL As String
Dim intI As Integer
On Error GoTo ErrorHandler
Set CalendarTEST = CurrentDb
strSQL = "SELECT * FROM TimeOff WHERE Exported = true"
Set rstTimeOff = CalendarTEST.OpenRecordset
DoCmd.GoToRecord , , acFirst
Set outobj = CreateObject("outlook.appl
Set outappt = outobj.CreateItem(olAppoin
intI = 1
With rstTimeOff
Do Until .EOF
.Edit
Set outobj = CreateObject("outlook.appl
Set outappt = outobj.CreateItem(olAppoin
With outappt
.Start = Me!DateOff
.Subject = Me!EmpInit
.Body = Me!Comments
.Save
End With
.Update
.MoveNext
intI = intI + 1
Loop
End With
rstTimeOff.Close
dbsCalendarTEST.Close
Set rstTimeOff = Nothing
Set dbsCalendarTEST = Nothing
Exit Sub
ErrorHandler:
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
Thanks in advance!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tried your suggestions but still got the error. I ended up finding the following link and it worked.
https://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/A_4316-Automate-Outlook-in-VBA-with-the-OutlookCreateItem-Class.html
Since you tried to assist me I'll award you partial points.
https://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/A_4316-Automate-Outlook-in-VBA-with-the-OutlookCreateItem-Class.html
Since you tried to assist me I'll award you partial points.
Need more detail. What is working and what is not?