i have this code that when u pick annually and enter 2 dates it adds the dates to database here is the code
Select Case Combo1(0).Text ' Combo1(0) is the zero(0) index of the combo box control array
Case "A"
Call Annually(Text1(0).Text, Text1(1).Text, Text1(2).Text)
it works fine if u enter a the dates say 20 jan 2010 - 20 jan 2013
it returns the following
11.375FNBS49 0 20100120 20110120
11.375FNBS49 1 20110120 20120120
11.375FNBS49 2 20120120 20130120
11.375FNBS49 3 20130120 20130120
which is right
but there could be a case where the dates in two of the text boxes are 20 jan 2010 - 20 jan 2013
but i want to say start at the 20 march 2010 - 20 jan 2013
so what i want to happen is the first entry is
20 jan 2010- 20 march 2010
and then go from the 20 march 2010 to the 20 jan 2013
how can i change my code for this to work
Code:
If Text1(4).Text = "" And Text1(5).Text = "" Then
Text1(4).Text = Text1(1).Text
Text1(5).Text = Text1(2).Text
Else
' User Entered Data So Use That
Text1(1).Text = Text1(4).Text
Text1(2).Text = Text1(5).Text
End IfCase "A"
Call Annually(Text1(0).Text, Text1(1).Text, Text1(2).Text)
Code:
Public Sub Annually(SecID As String, INTSTRTDTE As String, INTENDDTE As String)
Dim dteRunningDate As Date
Dim VDate As Date
Dim i As Integer
Dim intInterval As Integer
Dim sTempCalendar As String
Dim dte As Date
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, dteRunningDate))
dte = (DateAdd("m", 12, INTSTRTDTE))
' Vdate = (DateAdd("m", 12, INTSTRTDTE))
dteRunningDate = CheckDateRules(VDate)
dteRunningDate = Format(CDate(dteRunningDate), "dd mmm yyyy")
'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))
dte = (DateAdd("m", 12, dte))
dteRunningDate = CheckDateRules(dte)
dteRunningDate = Format(CDate(dteRunningDate), "dd mmm yyyy")
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 Subit works fine if u enter a the dates say 20 jan 2010 - 20 jan 2013
it returns the following
11.375FNBS49 0 20100120 20110120
11.375FNBS49 1 20110120 20120120
11.375FNBS49 2 20120120 20130120
11.375FNBS49 3 20130120 20130120
which is right
but there could be a case where the dates in two of the text boxes are 20 jan 2010 - 20 jan 2013
but i want to say start at the 20 march 2010 - 20 jan 2013
so what i want to happen is the first entry is
20 jan 2010- 20 march 2010
and then go from the 20 march 2010 to the 20 jan 2013
how can i change my code for this to work