VBA
(1)
Report
(1)
DatePart
(1)
VbMonday
(1)
Sebastian
(1)
MuchJohn
(1)
Tuesday
(1)
DreamsI
(1)

syntax for Week number

Asked By Revned
20-Mar-10 04:25 AM
Hi,

Can anyone help me how figure out a correct syntax for week no.

I have tblRev with fieldname:Date
I want access automatically display the week no. after
entering a Date in my field: Date.

Please can anyone help

Thanks

Hi,With Monday as a first day of week following code should be

sweet_dreams replied to Revned
20-Mar-10 05:20 AM
Hi,
With Monday as a first day of week following code should be helpful:

Format(Date, "ww",vbMonday)

Regards,
Sebastian

wrote:First off... it is best to NOT use the reserved word Date as a fieldname!

John W. Vinson replied to Revned
20-Mar-10 05:22 PM
First off... it is best to NOT use the reserved word Date as a fieldname!
Access can (and will!) get it confused with the builtin Date() function, and
give you strange errors.

That said, you can have a textbox on your form or report bound to the date
field, and set its Format property to "ww" to display the (1 to 54) week
number; for more control, you can use

=DatePart("ww", [datefield], <optional parameters>)

See the VBA help for DatePart; the parameters let you specify just what you
mean by the first week of the year (what day does the week start - Monday or
Sunday or some other day? Can the first week of the year be only one day long,
or should Week 1 be the week of the first Tuesday? etc.)
--

John W. Vinson [MVP]

Thank you very muchJohn W. Vinson and sweet_dreamsI really appreciate"John W.

Revned replied to John W. Vinson
20-Mar-10 11:54 PM
Thank you very much

John W. Vinson and sweet_dreams

I really appreciate
Post Question To EggHeadCafe