Creating Single Tasks

A single (nonrecurring) task can be created using either the SingleTasks table or the Tasks table, which contains the merged contents of the single and recurring tables. Because these tables are linked together, creating an item in one table automatically creates that item in the other table. For more information on the Tasks table, see Merged Tables.

    To create a single task
  1. Get the SingleTasks table from the global Schedule object.
  2. Use the New method to create a new item in the SingleTasks table.
  3. Set the desired properties on the item.
  4. Release the objects.

The following sample code creates a SingleTask object and sets several properties:

Sub CreateTask()
    Dim objTable As Object, objItem As Object
    Dim dt As Date
    
    'Get the SingleTasks table from the global Schedule object.
    Set objTable = gobjSchedule.SingleTasks
    
    dt = DateAdd("d", 1, Now)
    
    'Create a new item in the SingleTasks table.
    Set objItem = objTable.New
    
    'Set the desired properties on the item.
    objItem.SetProperties Text:="OLE: CreateTask " & Now(), _
        Notes:="Notes", _
        StartDate:=LConvertTo32bitDate(DateAdd("d", 1, dt)), _
        EndDate:=LConvertTo32bitDate(DateAdd("d", 2, dt))

    'Release item object
    Set objItem = Nothing
    
    'Release table object
    Set objTable = Nothing
    
End Sub