I have a table that contains dates of completion for a process. There are five different dates for each record. Each date represents the completeion of a step in the process. I am trying to calculate the workings days between each of these 5 dates. I use a function to calc the working days.
This is the code I wrote to update the working days once it is calculated. CountWorkdays is a function used to calculate the days.
How can I pass the field names to the Sub so I can call this and use it with each of the updates?
Sub CalcDays(sTable As String, sUpdateField As String, sDatefield As String, eDateField As String)
Dim db As dao.Database, rst As dao.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset(sTable, dbOpenDynaset)
Do Until rst.EOF
With rst
.Edit
!sUpdateField = (CountWorkdays(!sDatefield, !eDateField))
.Update
.MoveNext
End With
Loop
rst.Close
db.Close
End Sub
This is the code I wrote to update the working days once it is calculated. CountWorkdays is a function used to calculate the days.
How can I pass the field names to the Sub so I can call this and use it with each of the updates?
Sub CalcDays(sTable As String, sUpdateField As String, sDatefield As String, eDateField As String)
Dim db As dao.Database, rst As dao.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset(sTable, dbOpenDynaset)
Do Until rst.EOF
With rst
.Edit
!sUpdateField = (CountWorkdays(!sDatefield, !eDateField))
.Update
.MoveNext
End With
Loop
rst.Close
db.Close
End Sub