hi
i have this code
what it does is people enter two dates and press monthly and it goes to every month on them dates. but if the days fall on a sat or sun it pick prev or next working day and from that date it goes on
so for eg start date say is the 25/01/10 and end date is 25/01/11
so it goes to first date 25/01/10 lets say thats a monday thats fine so it goes to the 25/02/10.
lets say thats a sun so the date that would be added to table is the 26/02/10
the way my code works is it adds the 26/02/10 to database and the next date it looks for is the 26/03/10
but what i want is for it to always look for the 25th
i have this code
Code:
Public Sub Monthly(SecID As String, INTSTRTDTE As String, INTENDDTE As String)
Dim dteRunningDate As Date
Dim i As Integer
Dim intInterval As Integer
Dim sTempCalendar As String
Dim sSql As String
Dim Seq As String
Dim sTempCCY As String
sSql = "DELETE FROM SCHC WHERE SECID = '" & UCase(text1(0).Text) & "'"
DBCALL "SELECT", "SCHC", sSql
Seq = 0
dteRunningDate = CheckDateRules(DateAdd("m", 1, INTSTRTDTE))
Do While dteRunningDate <= INTENDDTE
sSql = "INSERT INTO SCHC VALUES('" & SecID & "','" & Seq & "','" & INTSTRTDTE & "','" & dteRunningDate & "')"
DBCALL "SELECT", "SCHC", sSql
If result <> 100 Then
Message 43
result = 1
End If
'Debug.Print SecID & vbTab; Seq & vbTab; INTSTRTDTE & vbTab & dteRunningDate
INTSTRTDTE = dteRunningDate
dteRunningDate = CheckDateRules(DateAdd("m", 1, dteRunningDate))
Seq = Seq + 1
Loop
If dteRunningDate <> INTENDDTE Then
sSql = "INSERT INTO SCHC VALUES('" & SecID & "','" & Seq & "','" & INTSTRTDTE & "','" & INTENDDTE & "')"
DBCALL "SELECT", "SCHC", sSql
If result <> 100 Then
Message 43
result = 1
End If
End If
End Subso for eg start date say is the 25/01/10 and end date is 25/01/11
so it goes to first date 25/01/10 lets say thats a monday thats fine so it goes to the 25/02/10.
lets say thats a sun so the date that would be added to table is the 26/02/10
the way my code works is it adds the 26/02/10 to database and the next date it looks for is the 26/03/10
but what i want is for it to always look for the 25th