For I

  • Thread starter Thread starter Rich
  • Start date Start date
R

Rich

Guest
How can I change this which adds cal months into one which adds 28 days
For I = -1 To Period - 2
rst.AddNew
rst!DateDue = DateAdd("m", I + 1, StartDte)
 
I think (if I understand correctly) that this will work:

rst!DateDue = DateAdd("d", I + 28, StartDte)
 
Thanks Mike I'd already tried that sadly no go, logic would seem to be that this should work but it brings errors in debug
rst!DateDue = DateAdd("dd",28 I + 1, StartDte)

[This message has been edited by Rich (edited 08-10-2001).]
 
Rich,

I worried about this one for a while then had a look in DateAdd() help.

Apparently there is no "dd" option only "d".

Could that be the cause of your problem?

Ian
 
Thanks Ian but sadly not, the problem is with trying to add 28 days and then getting the function to fill a table depending on the value of I.It works simply using "m" but I don't want calendar months.
 
Hi Rich,

this may not help as i'm not totaly sure of what you're doing. What i'm thinking is that you have a start date and want to go on adding 28 days to the date, translating each block into a number that starts with -1 and gets incremented to whatever

Code:
Dim dtmEnd As Date
    Dim dtmStart As Date
    Dim intPeriod As Integer
    
    dtmStart = #1/1/01#
    dtmEnd = #12/1/01#
    intPeriod = -1
    Do While dtmStart < dtmEnd 'or a datediff<28 days or whatever
        dtmStart = DateAdd("d", 28, dtmStart)
        intPeriod = intPeriod + 1
    Loop

There's kind of 2 things mixed up in there but maybe one of them is some use? (and maybe not... )

HTH

Drew
 
Thanks Drew what the function actually does is just to fill a table with dates based on the start date and the period I. If the start date is say 01/01/01 I get a list in a table of 01/01/01,01/02/01,and so on depending on the period. I use the dates for comparison purposes and they are then deleted. I don't have a problem with the cal mnthly dates but I would now like the interval to be 28 days instead. Here's what I have at the moment
Set DB = CurrentDb
Set rst = DB.OpenRecordset("DateDue")
rst.MoveFirst
For I = -1 To Period - 2
rst.AddNew
rst!DateDue = DateAdd("m", I + 1, stDte)
rst!ContrID = Forms!frmContracts![ContrID]

rst.Update
rst.MoveNext
Next I
rst.Close
Set rst = Nothing
DB.Close
Set DB = Nothing
I just can't figure out how!
 
is there something special I'm missing about the DateAdd function. Is there any reason you can't say:

rst!DateDue = StartDte + 28

i think i'm missing part of the puzzle?
 
No it needs the for I part to determine the no of months to produce, I've actually sussed it now I think, just have to check numerous outputs against a calendar to verify.
Thanks all
 
not very sure, but:

rst!DateDue = DateAdd("d", (I + 1) * 28, stDte)

note: + 1 is used because you started with For with -1, result should be greater than stDte.
 
Thanks Joey I've changed the for I period -1 that just sets the starting point, I now use this which seems to be o.k. I * 28.
 

Users who are viewing this thread

Back
Top Bottom