Example 9 - Microsoft Access graphic file generation

Creates a schedule using Microsoft Access VBA

 

 

Public Sub CreateSchedule()

' this function updates the schedule using data from a table

Dim dbsCurrent As Database
Dim rstTable1 As Recordset
Dim percentcomplete As Double
Dim numberoftasklines As Integer
Dim numberofsymbols As Integer
Dim x As Integer
Dim x2 As Integer
Dim TaskNumber As Integer
Dim tempstring As String

'Identify the table
Set dbsCurrent = CurrentDb()
Set rstTable1 = dbsCurrent.OpenRecordset("scheduledata", dbOpenTable)
Set objMilestones = CreateObject("Milestones")

With objMilestones
' Locate first record.
    rstTable1.MoveFirst
' Activate Milestones Professional Schedule
        .Activate

'Start with a template
        .Template "AccessExample.mtp"
        .Refresh
        .setmiscproperty "Use4DigitYears", "1"
      
TaskNumber = 0

   'Start of loop
   Do Until rstTable1.EOF
    TaskNumber = TaskNumber + 1

        On Error GoTo SkipDate
        tempstring = rstTable1!percentcomplete
        
        .SetOutlineLevel TaskNumber, rstTable1!OutlineLevel
        'Use Milestones Etc. OLE Automation calls to add symbols to the schedule
        If rstTable1!OutlineLevel = 1 Then
        .AddSymbol TaskNumber, Format(rstTable1!StartDate, "mm/dd/yy"), 1, 1, 2
        .AddSymbol TaskNumber, Format(rstTable1!EndDate, "mm/dd/yy"), 2, 1, 2
        End If
        If rstTable1!OutlineLevel > 1 Then
        .AddSymbol TaskNumber, Format(rstTable1!StartDate, "mm/dd/yy"), 1, 1, 2
        .AddSymbol TaskNumber, Format(rstTable1!EndDate, "mm/dd/yy"), 2, 1, 2
        End If
SkipDate:
        'Add information to the task columns
        .PutCell TaskNumber, 1, rstTable1!Manager
        .PutCell TaskNumber, 3, rstTable1!Task
        .PutCell TaskNumber, 6, Str(rstTable1!Funding1999)
        .PutCell TaskNumber, 7, Str(rstTable1!Funding2000)
        If Len(tempstring) > 0 Then
          .setpercentcomplete TaskNumber, CDbl(tempstring)
        End If
        
   
        .RefreshTask TaskNumber
        'Move to the next record
        rstTable1.MoveNext
   Loop
   
   ' End of loop.
        .SetLinesPerPage TaskNumber
        .SetTitle1 "ACCESS OLE AUTOMATION EXAMPLE"
        .SetTitle2 "Milestones Professional"
        .SetStartAndEndDates "1/1/2023", "12/31/2024"
         
        .Refresh
        
   'Close Access Table
   rstTable1.Close

   'Keep Milestones, Etc. schedule open
    .KeepScheduleOpen
End With
    

Exit Sub
   
End Sub

 

Table:

scheduledata
OutlineLevel Task Manager Budget Actual StartDate PercentComplete EndDate
1 Task 1 Jane $0.00 $0.00   0  
2 Task 1-1 John $234.00 $400.00 4/1/2023 44 6/30/2023
2 Task 1-2 Patrick $345.00 $200.00 5/1/2023 33 10/31/2023
2 Task 1-3 Glen $456.00 $400.00 7/15/2023 22 2/3/2024
1 Task 2 Mary $0.00 $0.00   0  
2 Task 2-1 Donald $999.00 $343.00 3/1/2023 99 6/30/2023
2 Task 2-2 Sue $342.00 $999.00 4/1/2023 44 6/6/2024
2 Task 2-3 Cariel $543.00 $434.00 5/15/2023 55 12/15/2024
2 Task 2-4 Jackie $5,000.00 $2,000.00 5/15/2023 33 12/1/2024
2 Task 2-5 Carl $342.00 $342.00 3/1/2023 22 4/1/2023
1 Task 3 Kirk $0.00 $0.00   0  
2 Task 3-1 Dave $500.00 $444.00 6/1/2023 15 6/30/2024
2 Task 3-2 Jane $460.00 $555.00 5/1/2023 23 5/1/2024
2 Task 3-3 Earl $300.00 $232.00 4/4/2023 33 6/19/2024
2 Task 3-4 Jane $200.00 $250.00 4/4/2023 44 4/20/2024
2 Task 3-5 Dave $1,000.00 $2,200.00 4/4/2023 55 6/6/2024
2 Task 3-6 Kirk $332.00 $232.00 4/4/2023 66 1/18/2024
2 Task 3-7 Carl $332.00 $332.00 4/4/2023 77 6/6/2024
2 Task 3-8 Jackie $332.00 $232.00 4/4/2023 88 5/10/2024
1 Task 4 Cariel $0.00 $0.00   0  
2 Task 4-1 Sue $332.00 $400.00 4/4/2023 22 7/29/2024
2 Task 4-2 Donald $200.00 $232.00 4/4/2023 33 11/26/2024
2 Task 4-3 Mary $350.00 $232.00 4/4/2023 44 12/29/2024
2 Task 4-4 Jim $500.00 $525.00 4/4/2023 55 8/4/2023

 

AccessExample.MTP:

 

 

Resulting schedule:

Related Topics

  1. AddSymbol
  2. PutCell

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

To effectively program with this interface, it's important to learn all about Milestones Professional.  Learn about Milestones.

Milestones Professional 2025 Automation Methods and Properties.  © Copyright 2000-2025, KIDASA Software, Inc. All rights reserved.