dateadd() as part of a loop not working

J

James Frater

Hello Everyone,

I've got a loop running, however it always seems to miss off the first date,
so any help would be greatly appreciated.

So, the fields/data I have are:

[startdate] = 18/01/2009
[enddate] = 08/03/2009
[totalweeks] = 7 (this is a datepart() calculation)

Once the code is run I should end up with
1 18/01/2009
2 25/01/2009
3 01/02/2009
4 08/02/2008
5 15/02/2009
6 22/02/2009
7 01/03/2009
8 08/03/2009

but what I'm getting is:
1 25/01/2009
2 01/02/2009
3 08/02/2008
4 15/02/2009
5 22/02/2009
6 01/03/2009
7 08/03/2009

I've tried using a "+1" in various places however it still won't add in the
first date.

intcounter = 0
intstartdate = Me![StartDate]

Do While intcounter <= Me![TotalWeeks]
intcounter = intcounter + 1
intstartdate = DateAdd("d", 7, intstartdate)
rstprogramme.AddNew
rstprogramme!Fixture= intcounter
rstprogramme!EventName = Me![EventName]
rstprogramme!EventStart= intstartdate
rstprogramme.Update

If intcounter = Me![TotalWeeks] Then
Exit Do
End If
Loop
 
J

James Frater

Sorry Chaps,

I managed to work it out on my own (I think I just needed to write it down
first!!!).

JAMES
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top