Hello everyone - I have an existing module in Excel that I would like to convert into a module that can work in Access instead. I am not familiar with Access VBA at all, so I don't even know where to begin. If anyone could help me get a start, I would be delighted.
Here is the VBA for Excel:
Code:
Public Function CountExtensions(CurrentDueDate As Date, DueDateExtensionHistory As String) As Integer
Dim StrDates() As String
Dim DueDates() As Date
Dim ExtCount As Integer
'Checks for null field
If DueDateExtensionHistory = "" Then
CountExtensions = 0
Exit Function
End If
'Checks for trailing char return
If Right(DueDateExtensionHistory, 1) = Chr(10) Then
DueDateExtensionHistory = Left(DueDateExtensionHistory, Len(DueDateExtensionHistory) - 1)
End If
'Loads an array of strings of dates
StrDates = Split(DueDateExtensionHistory, Chr(10))
ReDim DueDates(UBound(StrDates()))
'Converts the string dates into dates to prepare for comparison
i = 0
For i = 0 To UBound(StrDates())
DueDates(i) = DateValue(StrDates(i))
Next i
'Calculates Extensions
ExtCount = 0
For i = 0 To UBound(DueDates())
'Size of the array
If i = UBound(DueDates()) Then
If CurrentDueDate > DueDates(i) Then
ExtCount = ExtCount + 1
End If
Else
If DueDates(i + 1) > DueDates(i) Then
ExtCount = ExtCount + 1
End If
End If
Next i
CountExtensions = ExtCount
End Function