Oops... I put a "1" instead of "i" in the DateAdd function arguments, so it
would only add one month each time through the loop.  Here's the correct
syntax:

===========================
Dim months As Integer
Dim projectedDate As Date

months = Val(InputBox "Enter the number of Months to project")

For i = 1 To months
    projectedDate = DateAdd("m", i, Date)
    ' Insert data into table here
Next i
===========================

HTH,
Toby

----- Original Message ----- 
From: "Toby Bierly" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, June 22, 2005 2:03 PM
Subject: Re: [AccessDevelopers] Re: How to increment a date value


> I believe the DateAdd function is what you are looking for.  Example:
> ===========================
> Dim months As Integer
> Dim projectedDate As Date
>
> months = Val(InputBox "Enter the number of Months to project")
>
> For i = 1 To months
>     projectedDate = DateAdd("m", 1, Date)
>     ' Insert data into table here
> Next i
> ===========================
>
> HTH,
> Toby
>
> ----- Original Message ----- 
> From: "bronicabill" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Wednesday, June 22, 2005 1:48 PM
> Subject: [AccessDevelopers] Re: How to increment a date value
>
>
> > I'm writing code that will populate a table with projected dollar
> > amounts by month for a period of time input by the user when the
> > procedure runs.
> >
> > What I need to have happen is my code will generate a record where one
> > field is the current month and year, then the next record it generates
> > will need to be for the following month with a new projected dollar
> > amount, and will continue until a specific number of iterations have
> > been completed. When this code is first started, an InputBox pops up
> > to ask the user how many months he/she would like to generate data
> > for. The number entered is how many times a new record will be
> > created, and the date field needs to increment one month at a time for
> > each new record.
> >
> > Hope this explains it a bit better.  ;-)
> >
> > Thanks,
> >
> > Bill R.
> >
> >
> > --- In [email protected], "Eric Douglas"
> > <[EMAIL PROTECTED]> wrote:
> > > Bill,
> > >
> > > Is this in a table, or on a form?  When you say, "one month at a
> > time
> > > for X months", do you mean that you want to add records to a table
> > with
> > > each value, or do you want a single control on a form to show an end
> > > result of the final date?
> > >
> > > Or do you want it to increment by exactly one month until the user
> > > performs some action, then increment another month, etc?
> > >
> > > With a little more info, I (or others) may be able to help.
> > >
> > > Eric
> > >
> > >
> > > > -----Original Message-----
> > > > From: [email protected]
> > > > [mailto:[EMAIL PROTECTED] On Behalf Of bronicabill
> > > > Sent: Wednesday, June 22, 2005 1:12 PM
> > > > To: [email protected]
> > > > Subject: [AccessDevelopers] How to increment a date value
> > > >
> > > > I am writing some code that needs to increment a date field
> > > > by one month at a time for X number of months. As simple as
> > > > it sounds, I have not yet found a way to do this!
> > > >
> > > > If anyone can tell me an easy way to do this, I would greatly
> > > > appreciate it!
> > > >
> > > > Thanks in advance,
> > > >
> > > > Bill Rainey
> > > > [EMAIL PROTECTED]
> >
> >
> >
> >
> >
> > Please zip all files prior to uploading to Files section.
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
>
>
>
> Please zip all files prior to uploading to Files section.
> Yahoo! Groups Links
>
>
>
>
>
>




Please zip all files prior to uploading to Files section. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AccessDevelopers/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to