Calendar functions

cavscout

Registered User.
Local time
Today, 04:04
Joined
Mar 13, 2003
Messages
74
I want to have a user enter a MM/DD/YY value and then have access populate a table with the Monday and Friday Dates for each week. I think if I can tap into the system calendar it may be possible.

Has anyone done something like this? Your help is greatly appreciated. I don't want the end user to have to enter each weeks date range.

I'm using access 97.

Thanks.
 
Here's kind of a simplified version of what you need to do. I have a form with two text boxes where the user enters in a start date and a date to calculate through. It also has a command button to run the code. It populates a table that I have called MyTable:

Code:
Private Sub Command2_Click()
Dim dbs As Database
Dim rst As Recordset
Dim HoldStart As Date

    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("MyTable")
    HoldStart = Me.TxtB_FromDate
    Do Until WeekDay(HoldStart) = vbMonday
        HoldStart = DateAdd("d", 1, HoldStart)
    Loop
    Do Until HoldStart > Me.TxtB_ToDate
        rst.AddNew
        rst!TheMonday = HoldStart
        rst!Thefriday = DateAdd("d", 4, HoldStart)
        rst.Update
        HoldStart = DateAdd("ww", 1, HoldStart)
    Loop
    
rst.Close
dbs.Close
    
End Sub
Let me know if that works for you.
HTH
 

Users who are viewing this thread

Back
Top Bottom