|
![]() |
| This example shows how you might display a Milestones Professional schedule based on data in a Microsoft Access database. The same technique can be applied to other database systems. | |||||||||||||||
| In this case, the MS Access database includes 3 tables (table1, table2, and table3). When the Main() sub is executed (in the Milestones module), a form is presented. It is initially populated with a schedule using dates from table1. From then on, the user can press one of 3 buttons labeled "Table1", "Table2", or "Table3" and cause Milestones to change the picture which is displayed. This is accomplished by keeping a Milestones Professional schedule object open while the MS Access application is open and closing it when the MS Access application closes. While open, when the user presses one of the button, the software will:
|
|||||||||||||||
|
|
|||||||||||||||
| (We are not experts at MS Access programming. This example is offered to illustrate the use of Milestones Professional interface calls and give you ideas for your programming projects. This code is not complete and is not meant to be used as part of any of your projects.) | |||||||||||||||
| The Form: | |||||||||||||||
![]() |
|||||||||||||||
| The Access Visual Basic Program: | |||||||||||||||
| Public dbsCurrent As
Database Public rstTable1 As Recordset Public numberoftasklines As Integer, numpages As Integer Public x As Integer Public x2 As Integer Public TaskNumber As Integer Public objmilestones As Object Public StartDate As String, finishdate As String, schedulestartdate As String, schedulefinishdate As String Public xDatediff As Long Public title As String Public selectedtable As String Sub main() Set rstTable1 =
dbsCurrent.OpenRecordset("table1", dbOpenTable) formatmilestonesschedule Form_Form1.showstuff End Sub Public Sub CreateSchedule() schedulestartdate = "12/31/2399" ' this function updates the schedule using data from a table With objmilestones 'check Milestones object and see if it
has been used. On Error GoTo done finishdate = Format(rstTable1!EndDate,
"mm/dd/yy") .AddSymbol TaskNumber, StartDate, 1, 1,
2 done: ' Create a bitmap with the new schedule ' pause to give bitmap time to save
before going on Exit Sub End Sub Sub closeout() 'Keep Milestones, schedule open End Sub Sub timeout() Dim PauseTime, Start, Finish, TotalTime objmilestones.setcolumnproperty 2,
"Width", 1.6 objmilestones.setcolumnproperty 11,
"Width", 1 objmilestones.setcolumnproperty 12,
"Width", 1 |
|||||||||||||||
| In the Form1 Module: | |||||||||||||||
|
Option Compare Database Private Sub Command4_Click() Set Milestones1.rstTable1 =
dbsCurrent.OpenRecordset("table2", dbOpenTable) Milestones1.CreateSchedule Private Sub Command5_Click() Milestones1.selectedtable = "table1" Image3.Picture = "c:\milestones.bmp" End Sub Private Sub Command6_Click() Set Milestones1.rstTable1 =
dbsCurrent.OpenRecordset("table3", dbOpenTable) Image3.Picture = "c:\milestones.bmp" Public Sub showstuff()
|
|||||||||||||||
| To try this example: | |||||||||||||||
| Click here to download a self-extracting EXE file containing the above code. | |||||||||||||||
| (This download is recommended for experienced Access users who are also experience programmers.) | |||||||||||||||
| For other examples, look at the Excel Example page. Anything that can be done in Excel can also be done in Access. | |||||||||||||||
| Click here to visit our main programmer's page. |


