August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!
****CODE START**** Option Explicit Dim outObj As New Outlook.Application Dim outNS As Outlook.NameSpace Dim outFolders As Outlook.MAPIFolder Dim outSubFolders As Outlook.MAPIFolder Dim outAppt As Outlook.AppointmentItem Dim strMail, strFirst, strLast As String Dim intCount As Integer Dim frm As Form Function addAppt() ' Save record first to be sure required fields are filled. DoCmd.RunCommand acCmdSaveRecord ' Exit the procedure if appointment has been added to Outlook. Set frm = Screen.ActiveForm If frm.AddedToOutlook = True Then MsgBox "This appointment already added to Microsoft Outlook" Exit Function Else 'Set the name of the Mailbox frm.Auditor.SetFocus strMail = frm.Auditor.Text intCount = InStrRev(strMail, " ") strFirst = Trim$(Left$(strMail, intCount)) strLast = Trim$(Right$(strMail, intCount)) strMail = "Mailbox - " & strLast & ", " & strFirst ' Add a new appointment. Set outNS = outObj.GetNamespace("MAPI") Set outFolders = outNS.Folders(strMail) Set outSubFolders = outFolders.Folders("Calendar") Set outAppt = outObj.CreateItem(olAppointmentItem) With outAppt .Start = frm.ApptDate & " " & frm.ApptTime .Duration = frm.ApptLength .Subject = frm.Appt If Not IsNull(frm.ApptNotes) Then .Body = frm.ApptNotes If Not IsNull(frm.ApptLocation) Then .Location = _ frm.ApptLocation If frm.ApptReminder Then .ReminderMinutesBeforeStart = frm.ReminderMinutes .ReminderSet = True End If .Save End With End If ' Release the Outlook object variable. Set outObj = Nothing ' Set the AddedToOutlook flag, display a message. frm.AddedToOutlook = True DoCmd.RunCommand acCmdSaveRecord MsgBox "Appointment Added!" Exit Function AddAppt_Err: MsgBox "Error " & Err.Number & vbCrLf & Err.Description Exit Function End Function ****CODE END****
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.