Create a project plan
In this tutorial, you create a task table and a dependency table, place a WklGantt on a form, bind
it, and then change the schedule in Form view with the mouse while the dependent task follows
automatically. It takes about fifteen minutes.
Prerequisites
- Microsoft 365 Access or the Access Runtime, 32-bit or 64-bit, with the WKL Forms Object Library 1.23 or later installed and registered for the current Windows user (How to: Install the released package).
- A new database in a trusted location.
- Every WKL control opens its designer the same way: in Design view, open the property sheet (F4), go to the Other tab, and click
[...]in the Custom row (Opening the designer).
Steps
1. Create the sample tables
Run these lines in the Immediate window (Ctrl+G), one by one:
CurrentDb.Execute "CREATE TABLE tblTasks (TaskID COUNTER PRIMARY KEY, ParentID LONG, TaskName TEXT(50), StartDate DATETIME, FinishDate DATETIME, Done DOUBLE, Resources TEXT(100))" CurrentDb.Execute "CREATE TABLE tblLinks (LinkID COUNTER PRIMARY KEY, FromID LONG, ToID LONG, LinkType LONG, Lag DOUBLE)" CurrentDb.Execute "INSERT INTO tblTasks (ParentID, TaskName, StartDate, FinishDate, Done) VALUES (0, 'Project', #10/5/2026#, #10/12/2026#, 0)" CurrentDb.Execute "INSERT INTO tblTasks (ParentID, TaskName, StartDate, FinishDate, Done) VALUES (1, 'Planning', #10/5/2026#, #10/6/2026#, 100)" CurrentDb.Execute "INSERT INTO tblTasks (ParentID, TaskName, StartDate, FinishDate, Done, Resources) VALUES (1, 'Building', #10/7/2026#, #10/9/2026#, 40, 'Miller')" CurrentDb.Execute "INSERT INTO tblTasks (ParentID, TaskName, StartDate, FinishDate, Done) VALUES (1, 'Acceptance', #10/12/2026#, #10/12/2026#, 0)" CurrentDb.Execute "INSERT INTO tblLinks (FromID, ToID, LinkType, Lag) VALUES (2, 3, 0, 0)" CurrentDb.Execute "INSERT INTO tblLinks (FromID, ToID, LinkType, Lag) VALUES (3, 4, 0, 0)"
LinkType 0 means finish-to-start. The finish is a task's last working day, without a time.
2. Insert the control
Create a blank form, save it as frmPlan, and stay in Design view. Choose Form Design › Controls ›
ActiveX Controls, select WKL Gantt, click OK, draw the control across the width of the
form, and name it Gantt1. Save the form.
3. Bind the chart
With the form still open in Design view, insert a standard module with this procedure, place the cursor inside it, and press F5:
Public Sub DefinePlan()
With Forms!frmPlan!Gantt1.Object
.RecordSource = "tblTasks"
.KeyField = "TaskID": .ParentField = "ParentID": .TextField = "TaskName"
.ExpandLevel = 9
.StartField = "StartDate": .FinishField = "FinishDate": .ProgressField = "Done"
.ResourcesField = "Resources"
.DependencySource = "tblLinks"
.PredecessorField = "FromID": .SuccessorField = "ToID"
.LinkTypeField = "LinkType": .LagField = "Lag"
.ScheduleMode = wgsAutomatic
.ShowCriticalPath = True
.Columns.Add("TaskName", "Task").Width = 2200
.Columns.Add("StartDate", "Start").Format = "Short Date"
.Columns.Add("FinishDate", "Finish").Format = "Short Date"
.TreeColumn = "TaskName"
End With
DoCmd.Close acForm, "frmPlan", acSaveYes
End Sub
You can also make the same settings without code: property sheet, Custom row, [...], on the
designer's Record source, Columns, Tasks, Dependencies, and Calendar and scheduling pages.
4. Move a task
Open frmPlan in Form view. Point to the middle of the Building bar, press the left mouse
button, drag the bar one day to the right, and release it.
Expected result
- Before step 4: Project appears as a summary bar from Oct 5 to Oct 12, 2026; Planning is complete (dark bar), Building is 40% complete with “Miller” to the right of it, and Acceptance is on Oct 12. The arrows run Planning › Building › Acceptance, and all three tasks are critical (red).
- While you drag, a dashed bar and a tooltip show the new dates.
- After step 4: Building runs from Oct 8 to Oct 12 (over the weekend); Acceptance has moved to Oct 13 because the schedule is automatic; and Project ends on Oct 13.
tblTaskscontains the new dates. A task you move by hand gets a “Start No Earlier Than” constraint, just as in Microsoft Project. The constraint is saved only whenConstraintTypeFieldandConstraintDateFieldare mapped; without them, the next Reschedule project moves Building back to right after Planning.
Next steps
- How to: Plan tasks with dependencies: manual mode, predecessor text, the calendar, and the shortcut menu commands.
- How to: Export the chart to Excel, an image, or PDF.
- Overview of the concepts.