Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Apr 2002
    Location
    Burlington, Washington, USA
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date Looping (Win2000 SP4)

    I am trying to find a procedure that will work in a sub form that will create new 20 records for a date field that will increment each record by one week. This is what I have so far. Please let me know what I am doing wrong.

    Thank you,
    Larry

    Private Sub CycleDate_DblClick()
    Dim D As Integer
    Dim DayCount As Integer
    Dim CycleDate As Date

    DayCount = 7

    For D = 1 To 20

    Me..CycleDate = [CycleDate]+[DayCount]
    DoCmd.RunCommand (acCmdRecordsGoToNew)

    Next D

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Date Looping (Win2000 SP4)

    Apparently this is the On Dbl Click event procedure for a control named CycleDate. It's confusing to have a variable named CycleDate in this procedure. I would rename this variable.
    There should be only one period between Me and CycleDate.
    You should create a new record first, then set the CycleDate control/field.
    There is no need to prefix RunCommand with DoCmd.

    Private Sub CycleDate_DblClick()
    Dim D As Long
    Dim DayCount As Long
    Dim dtmDate As Date

    DayCount = 7
    dtmDate = Me.CycleDate

    For D = 1 To 20
    RunCommand acCmdRecordsGoToNew
    Me.CycleDate = dtmDate + D * DayCount
    Next D
    End Sub

  3. #3
    Lounger
    Join Date
    Apr 2002
    Location
    Burlington, Washington, USA
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date Looping (Win2000 SP4)

    Thank you. It works great.

    Larry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •