Increase date by one day

irade92

Registered User.
Local time
Today, 17:28
Joined
Dec 26, 2010
Messages
229
Hi
I am using this code:
Private Sub Command12_Click()
Dim mDate As Date
mDate = #1/8/2011#
Dim mSQL As String
Dim i As Integer

For i = 0 To 31

mSQL = "INSERT INTO tblFAKTURI ( BROJ_ID, MB_ID, DIJAG_ID, KOL, TEN_CENA, NAB_CENA, MARZA, IGUN, PARTIC, RANG_ID, DATUM, SPESUB_ID, DANOK_ID, DATPRE, VRABOTEN_ID )"
mSQL = mSQL & " SELECT tblMAISTORI.BROJ_ID, tblMAISTORI.MB_ID, tblMAISTORI.DIJAG_ID, tblMAISTORI.KOL, tblMAISTORI.TEN_CENA, tblMAISTORI.NAB_CENA, tblMAISTORI.MARZA, tblMAISTORI.IGUN, tblMAISTORI.PARTIC, tblMAISTORI.RANG_ID, tblMAISTORI.DATUM, tblMAISTORI.SPESUB_ID, tblMAISTORI.DANOK_ID, tblMAISTORI.DATPRE, tblMAISTORI.VRABOTEN_ID"
mSQL = mSQL & " FROM tblMAISTORI"
mSQL = mSQL & " WHERE (((tblMAISTORI.DATUM) = mDate ) And ((tblMAISTORI.FOND) = 'F'))"


DoCmd.RunSQL mSQL
i = i + 1
mDate = NewDate(mDate)


Next
end sub

Function NewDate(mDate As Date) As Date
mDate = DateAdd("d", i, mDate)
End Function

I want mDate to increase by one day until it reach 31 of august

Where I make mistake?
Thanks
 
The variable "i" has a scope limited to the sub it's declared in. You could make it a form level variable to it was available to both.
 

Users who are viewing this thread

Back
Top Bottom