473,435 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,435 software developers and data experts.

Day of week

46
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?

Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Load()
  2. Dim vDay As VbDayOfWeek
  3. If vDay = vbMonday Then
  4. Me.Label0.Visible = True
  5. Else
  6. Me.Label0.Visible = False
  7. End If
  8. End Sub
  9.  
thanks,
Jeff
Nov 12 '10 #1

✓ answered by ADezii

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

4 7302
ADezii
8,834 Expert 8TB
  1. vbDayOfWeek is an Enumeration which is illustrated below:
    Expand|Select|Wrap|Line Numbers
    1. Enum vbDayOfWeek
    2.   vbSunday = 1
    3.   vbMonday = 2
    4.   vbTuesday = 3
    5.   vbWednesday = 4
    6.   vbThursday = 5
    7.   vbFriday = 6
    8.   vbSaturday = 7
    9. End Enum
  2. An example of its possible usage would be:
    Expand|Select|Wrap|Line Numbers
    1. Dim dteDate As Date
    2.  
    3. dteDate = #11/12/2010#
    4.  
    5. If Weekday(dteDate) = vbFriday Then         'will evaluate to True
    6.   MsgBox "Finally, the work week is over!"
    7. Else
    8.   'Day other than Friday
    9. End If
Nov 12 '10 #2
jmar93
46
Works perfectly, thank you very much!

Jeff
Nov 12 '10 #3
ADezii
8,834 Expert 8TB
You are quite welcome.
Nov 12 '10 #4
just use the function
myday = WeekdayName(Weekday(mydate.Text) - 1)
on the current date to return the current day, I have a small testbed attached which shows this on form1.
Attached Files
File Type: zip testbed.zip (59.0 KB, 166 views)
Nov 13 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
21
by: .:mmac:. | last post by:
I have to update a page every week. I get the page ahead of time so I used the "scheduled includes" webbot in Frontpage only to find that I would have to refresh the page every week to have it...
7
by: Shuffs | last post by:
Could someone, anyone please tell me what I need to amend, to get this function to take Sunday as the first day of the week? I amended the Weekday parts to vbSunday (in my code, not the code...
14
by: deko | last post by:
This runs, but does not narrow to current week. suggestions appreciated! SELECT lngEid, dtmApptDate, Subject, Appt_ID FROM qry002 WHERE (dtmApptDate BETWEEN DateAdd("d",-weekday()+2,) And...
5
by: Peter Bailey | last post by:
I have a query that returns , and : 12/05/04 3 Wednesday 13/05/04 0 Thursday and so on what I would like to do now is count the number of bookings by week so from monday to...
9
by: Ray | last post by:
I need to convert the normal calendar to show the week no., the period no. and the financial year. The financial year format is as follows:- Date start: 2 May, 2005 7 days a week, 4 weeks a...
3
by: Steph. | last post by:
Hi, When I use the "Calendar.GetWeekOfYear" function (with "fr-BE" as CultureInfo and Monday as the first day of week) I get : Friday 31/12/2004 : week = 53
3
by: Mal | last post by:
Hello, Any advice on a function to convert a given week number to a date? Ideally I'd like the first day of that week. I'm using this to compare year to year....using the week number as the...
6
by: aarklon | last post by:
Hi folks, I found an algorithm for calculating the day of the week here:- http://www.faqs.org/faqs/calendars/faq/part1/index.html in the section titled 2.5 what day of the week was 2 august...
10
by: Jim | last post by:
I'm sure this has been asked before but I can't find any postings. I have a table that has weekly inspections for multiple buildings. What I need to do is break these down by the week of the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.