Private Sub cmdUpdateProjectData_Click()
On Error GoTo cmdUpdateProjectData_Click_Error
Dim db As DAO.Database
Dim rsICSProjectImport As DAO.Recordset
Dim rsDocumentDetail As DAO.Recordset
Dim rsLUWDetail As DAO.Recordset
Dim prjActive As Project
Dim tskAny As Task
Dim strICSProjectImport As String
Dim strDocumentDetail As String
Dim strLUWDetail As String
Dim strOpenProject As String
Dim strTDSERROR As String
Dim strHLDERROR As String
Dim strSQL As String
Dim strTestIn As String
Dim intCount As Integer
Dim intTrackCount As Integer
Dim intStartLen As Integer
Dim intFinishLen As Integer
Dim intActualStartLen As Integer
Dim intActualFinishLen As Integer
Dim intIntialLoadFlag As Integer 'Load dates if this is set
Dim intValUserVars As Integer
Dim intDEBUGTHIS As Integer
Dim varLoadtime As Variant
Dim varHLDLoadTime As Variant
Dim varTDSLoadTime As Variant
Dim varDumpTime As Variant
DoCmd.SetWarnings True
StartTimer
intDEBUGTHIS = 0
intIntialLoadFlag = 0 'Load dates if this is set
lblProgressStatus.Caption = ""
lblProgressStatus2.Caption = ""
lblProgressStatus3.Caption = ""
pbrProgressStatus.Visible = False
cmdCancel.Visible = False
DoCmd.RepaintObject acForm, "frmProjectImport"
intValUserVars = ValidateUserVars
If intValUserVars Then
MsgBox "Please correct your user variables!"
cmdUpdateProjectData.Transparent = True
cmdCancel.Caption = "Exit"
cmdCancel.Visible = True
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
Exit Sub
End If
' Purge Project table
lblProgressStatus.Caption = "Removing old data"
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
strSQL = "DELETE tblICSProjectImport.UniqueID From tblICSProjectImport;"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
varDumpTime = ElapsedTime
If intDEBUG > 1 Then Debug.Print "Dump Time = "; varDumpTime
lblProgressStatus.Caption = "Opening MS Project file " &
strContractorSchedule
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
strOpenProject = strMSProjectDirectory & "\" & strContractorSchedule
MSProject.Application.FileOpen Name:=strOpenProject
Set prjActive = MSProject.Application.ActiveProject
strICSProjectImport = "tblICSProjectImport"
strDocumentDetail = "tblDocumentDetail"
strLUWDetail = "tblLUWDetail"
intCount = 0
intTrackCount = 0
Set db = CurrentDb
Set rsICSProjectImport = db.OpenRecordset(strICSProjectImport,
dbOpenDynaset)
Set rsDocumentDetail = db.OpenRecordset(strDocumentDetail, dbOpenDynaset)
Set rsLUWDetail = db.OpenRecordset(strLUWDetail, dbOpenDynaset)
' Load Project data into tblICSProjectImport
lblProgressStatus.Caption = "Loading Project Data, please be patient!"
lblProgressStatus2.Visible = True
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
For Each tskAny In prjActive.Tasks
'Long loop removed
Next
FileExit pjDoNotSave
Dim i As Integer
Dim t As Integer
For i = 1 To 10
For t = 1 To 10000
Next
Next
varLoadtime = ElapsedTime
lblProgressStatus.Caption = "Load Time = " & varLoadtime
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
If intDEBUG > 1 Then Debug.Print "Load Time = "; varLoadtime
' Set the progress bar values
lblProgressStatus2.Visible = False
pbrProgressStatus.Visible = True
pbrProgressStatus.Min = 0
pbrProgressStatus.Max = rsICSProjectImport.RecordCount
pbrProgressStatus.Value = 0
' Find UniqueID in rsICSProjectImport and copy data into rsLUWDetail with
DocumentID
lblProgressStatus.Caption = "Loading TDS Data"
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
intCount = 0
rsICSProjectImport.MoveFirst
Do Until rsICSProjectImport.EOF
With rsICSProjectImport
strTDSERROR = rsICSProjectImport!UniqueID
rsLUWDetail.MoveFirst
DoCmd.RepaintObject acForm, "frmProjectImport"
Do Until rsLUWDetail.EOF
If Not IsNull(rsLUWDetail!UniqueIDTDSDev) Then
If !UniqueID = Val(rsLUWDetail!UniqueIDTDSDev) Then
' !UniqueID, !Release, !Name, !UniqueIDSuccessors,
!UniqueIDPredecessors, !Milestone, !OutlineLevel, !OutlineNumber,
!OutlineParent
If IsNull(rsLUWDetail!TDSWBS) Then
rsLUWDetail.Edit
rsLUWDetail!TDSWBS = !WBS
rsLUWDetail.Update
End If
If intIntialLoadFlag Then
rsLUWDetail.Edit
rsLUWDetail!TDSDevStart = !Start
rsLUWDetail!TDSDevFinish = !Finish
rsLUWDetail!TDSDevActualStart = !ActualStart
rsLUWDetail!TDSDevActualFinish = !ActualFinish
rsLUWDetail.Update
End If
If IsNull(!Start) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevStart = False
rsLUWDetail.Update
Else
If CDate(!Start) = rsLUWDetail!TDSDevStart Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevStart = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevStart = False
rsLUWDetail.Update
End If
End If
If IsNull(!Finish) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevFinish = False
rsLUWDetail.Update
Else
If CDate(!Finish) = rsLUWDetail!TDSDevFinish Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevFinish = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevFinish = False
rsLUWDetail.Update
End If
End If
If IsNull(!ActualStart) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevActualStart = False
rsLUWDetail.Update
Else
If CDate(!ActualStart) =
rsLUWDetail!TDSDevActualStart Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevActualStart = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevActualStart = False
rsLUWDetail.Update
End If
End If
If IsNull(!ActualFinish) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevActualFinish = False
rsLUWDetail.Update
Else
If CDate(!ActualFinish) =
rsLUWDetail!TDSDevActualFinish Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevActualFinish = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevActualFinish = False
rsLUWDetail.Update
End If
End If
intTrackCount = intTrackCount + 1
End If
End If
If Not IsNull(rsLUWDetail!UniqueIDTDSObjDev) Then
If !UniqueID = Val(rsLUWDetail!UniqueIDTDSObjDev) Then
' !UniqueID, !Release, !Name, !UniqueIDSuccessors,
!UniqueIDPredecessors, !Milestone, !OutlineLevel, !OutlineNumber,
!OutlineParent
If intIntialLoadFlag Then
rsLUWDetail.Edit
rsLUWDetail!TDSObjDevStart = !Start
rsLUWDetail!TDSObjDevFinish = !Finish
rsLUWDetail!TDSObjDevActualStart = !ActualStart
rsLUWDetail!TDSObjDevActualFinish = !ActualFinish
rsLUWDetail.Update
End If
If IsNull(!Start) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevStart = False
rsLUWDetail.Update
Else
If CDate(!Start) = rsLUWDetail!TDSObjDevStart Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevStart = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevStart = False
rsLUWDetail.Update
End If
End If
If IsNull(!Finish) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevFinish = False
rsLUWDetail.Update
Else
If CDate(!Finish) = rsLUWDetail!TDSObjDevFinish
Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevFinish = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevFinish = False
rsLUWDetail.Update
End If
End If
If IsNull(!ActualStart) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevActualStart = False
rsLUWDetail.Update
Else
If CDate(!ActualStart) =
rsLUWDetail!TDSObjDevActualStart Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevActualStart = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevActualStart = False
rsLUWDetail.Update
End If
End If
If IsNull(!ActualFinish) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevActualFinish = False
rsLUWDetail.Update
Else
If CDate(!ActualFinish) =
rsLUWDetail!TDSObjDevActualFinish Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevActualFinish = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevActualFinish = False
rsLUWDetail.Update
End If
End If
intTrackCount = intTrackCount + 1
End If
End If
If Not IsNull(rsLUWDetail!UniqueIDTDSCodeReview) Then
If !UniqueID = Val(rsLUWDetail!UniqueIDTDSCodeReview) Then
' !UniqueID, !Release, !Name, !UniqueIDSuccessors,
!UniqueIDPredecessors, !Milestone, !OutlineLevel, !OutlineNumber,
!OutlineParent
If intIntialLoadFlag Then
rsLUWDetail.Edit
rsLUWDetail!TDSCodeReviewStart = !Start
rsLUWDetail!TDSCodeReviewFinish = !Finish
rsLUWDetail!TDSCodeReviewActualStart =
!ActualStart
rsLUWDetail!TDSCodeReviewActualFinish =
!ActualFinish
rsLUWDetail.Update
End If
If IsNull(!Start) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewStart = False
rsLUWDetail.Update
Else
If CDate(!Start) =
rsLUWDetail!TDSCodeReviewStart Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewStart = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewStart = False
rsLUWDetail.Update
End If
End If
If IsNull(!Finish) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewFinish = False
rsLUWDetail.Update
Else
If CDate(!Finish) =
rsLUWDetail!TDSCodeReviewFinish Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewFinish = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewFinish = False
rsLUWDetail.Update
End If
End If
If IsNull(!ActualStart) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewActualStart = False
rsLUWDetail.Update
Else
If CDate(!ActualStart) =
rsLUWDetail!TDSCodeReviewActualStart Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewActualStart = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewActualStart =
False
rsLUWDetail.Update
End If
End If
If IsNull(!ActualFinish) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewActualFinish = False
rsLUWDetail.Update
Else
If CDate(!ActualFinish) =
rsLUWDetail!TDSCodeReviewActualFinish Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewActualFinish =
True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewActualFinish =
False
rsLUWDetail.Update
End If
End If
intTrackCount = intTrackCount + 1
End If
End If
rsLUWDetail.MoveNext
Loop
pbrProgressStatus.Value = pbrProgressStatus.Value + 1
lblProgressStatus.Caption = "TDS fields updated " &
intTrackCount & " - Elapsed time " & ElapsedTime & " - Project Records read "
& intCount
lblProgressStatus3.Caption = Int(pbrProgressStatus.Value * 100 / _
pbrProgressStatus.Max) & "%"
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
.MoveNext
intCount = intCount + 1
End With
Loop
varTDSLoadTime = ElapsedTime
If intDEBUG > 1 Then Debug.Print "TDS Time = "; varTDSLoadTime
' Find UniqueID in rsICSProjectImport and copy data into rsDocumentDetail
with DocumentID
pbrProgressStatus.Value = 0
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
intTrackCount = 0
intCount = 0
rsICSProjectImport.MoveFirst
Do Until rsICSProjectImport.EOF
With rsICSProjectImport
strHLDERROR = rsICSProjectImport!UniqueID
rsDocumentDetail.MoveFirst
DoCmd.RepaintObject acForm, "frmProjectImport"
Do Until rsDocumentDetail.EOF
If Not IsNull(rsDocumentDetail!UniqueIDHLDDev) Then
If !UniqueID = Val(rsDocumentDetail!UniqueIDHLDDev) Then
' !UniqueID, !Release, !Name, !UniqueIDSuccessors,
!UniqueIDPredecessors, !Milestone, !OutlineLevel, !OutlineNumber,
!OutlineParent
If IsNull(rsDocumentDetail!HLDWBS) Then
rsDocumentDetail.Edit
rsDocumentDetail!HLDWBS = !WBS
rsDocumentDetail.Update
End If
If intIntialLoadFlag Then
rsDocumentDetail.Edit
rsDocumentDetail!HLDDevStart = !Start
rsDocumentDetail!HLDDevFinish = !Finish
rsDocumentDetail!HLDDevActualStart = !ActualStart
rsDocumentDetail!HLDDevActualFinish =
!ActualFinish
rsDocumentDetail.Update
End If
If IsNull(!Start) Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevStart = False
rsDocumentDetail.Update
Else
If CDate(!Start) = rsDocumentDetail!HLDDevStart
Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevStart = True
rsDocumentDetail.Update
Else
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevStart = False
rsDocumentDetail.Update
End If
End If
If IsNull(!Finish) Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevFinish = False
rsDocumentDetail.Update
Else
If CDate(!Finish) =
rsDocumentDetail!HLDDevFinish Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevFinish = True
rsDocumentDetail.Update
Else
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevFinish = False
rsDocumentDetail.Update
End If
End If
If IsNull(!ActualStart) Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevActualStart = False
rsDocumentDetail.Update
Else
If CDate(!ActualStart) =
rsDocumentDetail!HLDDevActualStart Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevActualStart = True
rsDocumentDetail.Update
Else
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevActualStart = False
rsDocumentDetail.Update
End If
End If
If IsNull(!ActualFinish) Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevActualFinish = False
rsDocumentDetail.Update
Else
If CDate(!ActualFinish) =
rsDocumentDetail!HLDDevActualFinish Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevActualFinish = True
rsDocumentDetail.Update
Else
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevActualFinish = False
rsDocumentDetail.Update
End If
End If
intTrackCount = intTrackCount + 1
End If
End If
If Not IsNull(rsDocumentDetail!UniqueIDHLDReviewApprove) Then
If !UniqueID =
Val(rsDocumentDetail!UniqueIDHLDReviewApprove) Then
' !UniqueID, !Release, !Name, !UniqueIDSuccessors,
!UniqueIDPredecessors, !Milestone, !OutlineLevel, !OutlineNumber,
!OutlineParent
If intIntialLoadFlag Then
rsDocumentDetail.Edit
rsDocumentDetail!HLDReviewApproveStart = !Start
rsDocumentDetail!HLDReviewApproveFinish = !Finish
rsDocumentDetail!HLDReviewApproveActualStart =
!ActualStart
rsDocumentDetail!HLDReviewApproveActualFinish =
!ActualFinish
rsDocumentDetail.Update
End If
If IsNull(!Start) Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveStart = False
rsDocumentDetail.Update
Else
If CDate(!Start) =
rsDocumentDetail!HLDReviewApproveStart Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveStart =
True
rsDocumentDetail.Update
Else
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveStart =
False
rsDocumentDetail.Update
End If
End If
If IsNull(!Finish) Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveFinish = False
rsDocumentDetail.Update
Else
If CDate(!Finish) =
rsDocumentDetail!HLDReviewApproveFinish Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveFinish =
True
rsDocumentDetail.Update
Else
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveFinish =
False
rsDocumentDetail.Update
End If
End If
If IsNull(!ActualStart) Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveActualStart
= False
rsDocumentDetail.Update
Else
If CDate(!ActualStart) =
rsDocumentDetail!HLDReviewApproveActualStart Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveActualStart = True
rsDocumentDetail.Update
Else
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveActualStart = False
rsDocumentDetail.Update
End If
End If
If IsNull(!ActualFinish) Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveActualFinish
= False
rsDocumentDetail.Update
Else
If CDate(!ActualFinish) =
rsDocumentDetail!HLDReviewApproveActualFinish Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveActualFinish = True
rsDocumentDetail.Update
Else
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveActualFinish = False
rsDocumentDetail.Update
End If
End If
intTrackCount = intTrackCount + 1
End If
End If
rsDocumentDetail.MoveNext
Loop
intCount = intCount + 1
pbrProgressStatus.Value = pbrProgressStatus.Value + 1
lblProgressStatus.Caption = "HLD fields updated " &
intTrackCount & " - Elapsed time " & ElapsedTime & " - Project Records read "
& intCount
lblProgressStatus3.Caption = Int(pbrProgressStatus.Value * 100 / _
pbrProgressStatus.Max) & "%"
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
.MoveNext
End With
Loop
varHLDLoadTime = ElapsedTime
If intDEBUG > 1 Then Debug.Print "HLD Time = "; varHLDLoadTime
strSQL = "DELETE tblICSProjectImport.UniqueID From tblICSProjectImport;"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
varDumpTime = ElapsedTime
If intDEBUG > 1 Then Debug.Print "Dump Time = "; varDumpTime
lblProgressStatus.Caption = "Loading Data complete, Time " & varDumpTime
pbrProgressStatus.Visible = False
cmdCancel.Caption = "Exit"
cmdCancel.Visible = True
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
rsICSProjectImport.Close
rsDocumentDetail.Close
rsLUWDetail.Close
Set rsICSProjectImport = Nothing
Set rsDocumentDetail = Nothing
Set rsLUWDetail = Nothing
Set db = Nothing
' Write time stamp to the database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("usystblUserVariables", dbOpenDynaset)
Do Until rs.EOF
With rs
If rs.Fields(1).Value = "strDateLastProjectUpdate" Then
rs.Edit
rs.Fields(2).Value = CStr(Now)
rs.Update
Exit Do
End If
.MoveNext
End With
Loop
rs.Close
Set rs = Nothing
Set db = Nothing
StopTimer
If intDEBUG > 1 Then Debug.Print "Total Time = "; ElapsedTime
On Error GoTo 0
Exit Sub
cmdUpdateProjectData_Click_Error:
DoCmd.SetWarnings True
MsgBox "TDS:" & strTDSERROR & vbCrLf & _
"HLD:" & strHLDERROR & vbCrLf & _
"Error " & Err.Number & " (" & Err.Description & ") in procedure
ImportProjectData of Module modImportProjectData" _
& vbCrLf & "Debug " & intDEBUGTHIS
cmdCancel.Caption = "Exit"
cmdCancel.Visible = True
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
rsICSProjectImport.Close
rsDocumentDetail.Close
rsLUWDetail.Close
Set rsICSProjectImport = Nothing
Set rsDocumentDetail = Nothing
Set rsLUWDetail = Nothing
Set db = Nothing
StopTimer
End Sub