Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / May 2008

Tip: Looking for answers? Try searching our database.

dateadd() as part of a loop not working

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
James Frater - 09 May 2008 15:01 GMT
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
James Frater - 09 May 2008 15:28 GMT
Sorry Chaps,

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

JAMES

> Hello Everyone,
>
[quoted text clipped - 45 lines]
>     End If
> Loop
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.