Loop to add appointments from datasheet form (1 Viewer)

Integrate

Registered User.
Local time
Today, 13:45
Joined
Oct 20, 2013
Messages
27
Hi,
I have a datasheet form that the client uses to enter multiple appointments into that will then be added to outlook calendar. I have been looking for a way to add this into my code but am not sure how to do it.

I found the option of using .movenext but it seems it needs to be used with recordsets and that is about where I get lost.

My 8 week old baby is not allowing me much research time so any help is very much appreciated by this Access learner.

This is the code I currently use to add single appointments to Outlook
Code:
Private Sub cmdAddCalendar_Click()
     Me.Dirty = False
 
If Me.chkAddedtoOutlook = True Then
    MsgBox "This appointment has already been added to Microsoft Outlook", vbCritical
    ' Exit the procedure
    Exit Sub
Else
    ' Add a new appointment.
' Use late binding to avoid the "Reference" issue
Dim olapp As Object ' Outlook.Application
Dim olappt As Object ' olAppointmentItem
Dim i As Integer
Dim ctl As Control
Dim cat As Control
Dim olfolder As Object

If isAppThere("Outlook.Application") = False Then
    ' Outlook is not open, create a new instance
    Set olapp = CreateObject("Outlook.Application")
Else
    ' Outlook is already open--use this method
    Set olapp = GetObject(, "Outlook.Application")
End If
Set olfolder = olapp.GetNamespace("MAPI").PickFolder
   
    Set olappt = olfolder.Items.Add ' olAppointmentItem
  
    
    With olappt
    ' If There is no Start Date or Time on
    ' the Form use Nz to avoid an error
     
    ' Set the Start Property Value
    .Start = Nz(Me.DelDate, "") & " " & Nz(Me.txtTime, "")
    .Subject = Nz(Me.Delivery & " " & Me.OrderNumber & " " & Me.Customer & " " & Me.NumberofDoors, vbNullString)
    .Mileage = Nz(Me.OrderNumber, vbNullString)
    .Categories = Nz(Me.Stage, vbNullString)
    .ReminderSet = False
    
         .Save
    End With
    
    End If ' Release the Outlook object variables.
    Set olappt = Nothing
    Set olapp = Nothing    ' Set chkAddedToOutlook to checked
    Me.chkAddedtoOutlook = True
 
    ' Save the Current Record because we checked chkAddedToOutlook
      Me.Dirty = False
   
    ' Inform the user
    MsgBox "Appointment Added!", vbInformation
End Sub
 

Users who are viewing this thread

Top Bottom