Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2005
    Posts
    9

    Unanswered: Help !! VB or Access Code

    I have a delima. I am building a database that is date driven

    I am trying to do a work que so that, specific records due on a specific date it will appear in the form.

    I need to be able to have a query, table, or macro that will automatically populated records with due dates by the click of a command button.

    For instance if a project started on 1/01/06 and ended on 02/01/06. I need the system to create 4 records stating week 1 , week 2, week 3, and week 4 in a field,
    Is there a macro I can build that will automatically populate these records for me in a table without manually inputting each week?


    Help please quickly if possible

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    What's it pay?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,469
    Provided Answers: 10
    There are some date function we paly play with

    datediff differance between to dates
    dateadd add a number of day,week,months to a date

    so
    Code:
    Sub test(StartDate, EndDate)
    Dim Week_Count As Long
    Dim WeekSart As Date
    Dim WeekMark As Long
    Dim rst As Recordset
    Dim DB As Database
    Set DB = CurrentDb
    
    Set rst = DB.OpenRecordset("TABLENAME")
    
    Week_Count = DateDiff("ww", StartDate, EndDate)
    
    For WeekMark = 1 To Week_Count
    WeekSart = DateAdd("d", WeekMark * 7, StartDate)
    rst.AddNew
    rst.Fields("fieldname1") = WeekSart
    rst.Fields("fieldname2") = "bla"
    rst.Fields("fieldname3") = "More BLA"
    rst.Fields("fieldname4") = "and some more"
    rst.Update
    Next
    
    End Sub
    Once you have edirt the Feildname

    you should beable to just pass the

    call test(#01/01/06#,#02/01/06#)
    hope this help

    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.
    DONT WORRY ABOUT THOSE WHO TALK BEHIND YOUR BACK
    THEY'RE BEHIND YOU FOR A REASON

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    My money says the next post from him is "Where do I put the code".
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Nov 2005
    Posts
    9
    Thanks Myle this has really help me

Posting Permissions

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