Day of week

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmar93
    New Member
    • Mar 2008
    • 46

    Day of week

    Hi,

    I am using Access 2007. I have a report that has labels that need to be visible only on certain days of the week.
    I have tried the following code in the reports load event, but it doesn't work. Does anybody have any ideas?

    Code:
    Private Sub Report_Load()
    Dim vDay As VbDayOfWeek
    If vDay = vbMonday Then
    Me.Label0.Visible = True
    Else
    Me.Label0.Visible = False
    End If
    End Sub
    thanks,
    Jeff
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    1. vbDayOfWeek is an Enumeration which is illustrated below:
      Code:
      Enum vbDayOfWeek
        vbSunday = 1
        vbMonday = 2
        vbTuesday = 3
        vbWednesday = 4
        vbThursday = 5
        vbFriday = 6
        vbSaturday = 7
      End Enum
    2. An example of its possible usage would be:
      Code:
      Dim dteDate As Date
      
      dteDate = #11/12/2010#
      
      If Weekday(dteDate) = vbFriday Then         'will evaluate to True
        MsgBox "Finally, the work week is over!"
      Else
        'Day other than Friday
      End If

    Comment

    • jmar93
      New Member
      • Mar 2008
      • 46

      #3
      Works perfectly, thank you very much!

      Jeff

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        You are quite welcome.

        Comment

        • malcolmk
          New Member
          • Sep 2010
          • 79

          #5
          dayname from date

          just use the function
          myday = WeekdayName(Wee kday(mydate.Tex t) - 1)
          on the current date to return the current day, I have a small testbed attached which shows this on form1.
          Attached Files

          Comment

          Working...