Setting firstdayofweek

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to define the value of firstdayofweek across all modules, or
does it have to be done within every date expression?
The database I am creating uses weeks that run from Thursday to Wednesday. I
would like to define Thursday as the first day of the week for all date
functions within the database. Is this possible?
 
Put a public, global variable in a regular module, and make it equal to the
value (long integer) of 5. Then use that global variable in all your
expressions that take an argument for you to specify the "first day of the
week".
 
Hi,

Thanks for your help. I was really hoping that it was possible to change the
firstdayofweek default value, so that I could define it once and not have to
include the global constant in every expression.

On a related note, I have used the expression
Me.txtDay = WeekdayName(Weekday(varDate)))
to display the day name for a given date. However, for some reason, it
returns the day after the given date. If I expand the expression and define
the firstdayofweek for Weekday and WeekdayName, the result is correct. Any
idea why this will not work with the default values?
Thanks again.
 
What Region have you selected under Regional and Language Options in the
Control Panel?

The VBA Developer's Handbook (by Getz and Gelbert) states:
"Online help indicates that you can pass a second parameter to WeekDay,
indicating the first day of the week. In many countries, Monday is
considered the first day of the week, so most of the VBA date functions
allow you to specify what you consider to be the first day of the week. If
you don't specify a value, VBA uses the Windows setting for your local
country. If you specify a constant (vbSunday through vbSaturday) for this
parameter, VBA treats that day as the first day of the week and offsets the
return value accordingly."

http://msdn.microsoft.com/library/en-us/dnvbadev/html/pullingpiecesapart.asp

Unfortunately, I can't find details anywhere as to what the default is for
each Region.

Randy Birch shows how to determine the setting in
http://vbnet.mvps.org/code/locale/localedates.htm (Obligatory Warning:
Randy's site is aimed at VB programmers. Because there are significant
differences between the controls available for forms in VB and in Access,
not all of his samples can be ported directly to Access. At a quick look,
though, this particular one should be fine)

There is a iFirstDayOfWeek key in the registry under HKCU\Control
Panel\International, but I don't know what the possible values are (mine's
currently set to 6!)
 
Thanks Doug, I'll take a look at the site. My region settings are set to UK,
not sure what my default values are.
I think I'll resort to always specifiying the firstdayofweek jsut to be on
the safe side.

Thanks for that piece of code Tim, that'll come in handy. However, I was
using weekdayname and weekday as I need to perform calculations on the
weekday value. I'm just outputting to a text box for test purposes at the
moment.
 
Back
Top