功能:根据项目号和步骤ID,更新指定步骤完成时间。这里里边要匹配两个条件一个是项目ID “”projectID“” 另一个是 “”StepID“” 步骤ID。
Sub SaveFini()
Dim rs As New ADODB.Recordset
Dim cnn As String
Dim sql As String
Dim a() As String
Dim s() As String
pn = ThisWorkbook.Sheets("A3").Range("AF4").Value 'The location of the cell where the completion date is locate
a() = "U7"
a() = "U16"
a() = "U32"
a() = "U39"
a() = "AG7"
a() = "AG29"
a() = "AG42"
With ThisWorkbook.Sheets("A3")
'Extract the step name
s() = Left(.Range("L7").Value, )
s() = Left(.Range("L16").Value, )
s() = Left(.Range("L32").Value, )
s() = Left(.Range("L39").Value, )
s() = Left(.Range("X7").Value, )
s() = Left(.Range("X29").Value, )
s() = Left(.Range("X42").Value, ) cnn = "Provider=Microsoft.ACE.OLEDB.16.0;" & _
"Data Source=" & ThisWorkbook.Path & ".\A3db2019.accdb"
On Error Resume Next For n = To
sql = "select StepID,FiniDate,ProjectID from A3_Plan where projectID='" & pn & "'and StepID='" & s(n) & "'"
Set rs = New Recordset
rs.Open sql, cnn, ,
rs.Fields("FiniDate") = .Range(a(n)).Value
rs.Update
Next
End With
End Sub