Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2004
    Location
    Raleigh, NC
    Posts
    146

    Unanswered: Idenitfy a specific day of the week

    I want to add the following to my form:

    "Next Thursday is 10/28/04"

    The question is how would I do it? I've worked with DateAdd and the like to determine the number of days between two dates, but never anything like this. When I open the form I want this to be a static element and as soon as Thursday arrives, the date would automatically show the next Thursday of the month. I know how to use DateAdd to find a date "7" days from now, but I don't know how to identity that initial Thursday to kick things off. Any ideas?

  2. #2
    Join Date
    Feb 2004
    Location
    Canada
    Posts
    133
    I'll assume you want it to always be a Thursday. This is one way to do it, but it requires a bit of VBA code.
    In the VB window, create a new module (from INSERT menu) and paste the following code:

    Code:
    Function GetNxtThurs()
    Dim tdy As Integer 'Today
    tdy = Weekday(Now())
    
    Select Case tdy
        Case 1 'Sunday
            GetNxtThurs = Now() + 4
        Case 2 'Monday
            GetNxtThurs = Now() + 3
        Case 3 'Tuesday
            GetNxtThurs = Now() + 2
        Case 4 'Wednesday
            GetNxtThurs = Now() + 1
        Case 5 'Thursday
            GetNxtThurs = Now() + 7
        Case 6 'Friday
            GetNxtThurs = Now() + 6
        Case 7 'Saturday
            GetNxtThurs = Now() + 5
    End Select
    
    End Function
    Then on your form, with a text box selected, paste the following in the text box's Control Source in the properties window:

    ="Next Thursday is " & Format(GetNxtThurs(),"mm/dd/yy")

    Hope this is what you're after.

  3. #3
    Join Date
    Sep 2004
    Location
    Raleigh, NC
    Posts
    146
    Gives me #Name? in the text box?

  4. #4
    Join Date
    Sep 2004
    Location
    Raleigh, NC
    Posts
    146
    Nevermind, typo'd. Thank you very much!

  5. #5
    Join Date
    Sep 2004
    Location
    Raleigh, NC
    Posts
    146
    Figured this one out also. Thanks again.
    Last edited by smacdonaldnc; 10-22-04 at 02:20.

Posting Permissions

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