Solved

How get week number in a text box on a report

Posted on 2012-12-29
5
686 Views
Last Modified: 2012-12-29
On a report I have 52 text boxes arranged vertically.  In the first box I want the value of the textbox to be the 1st week of the year's number (1).  In the next textbox I want the 2nd week of the year's number (2). So the end result will be:

1
2
3
4
5
6
etc.

I could be using labels to designate the value but the reason I need a calculated value is because I'm going to use that value in a formula in another textbox to the right of each week's number textbox.

Make sense?  What is the control source I need to enter to get the week number?

I tried = DatePart(“ww”,Date(#01/01/2012#)) but obviously that isn't working.
0
Comment
Question by:SteveL13
  • 3
5 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 38729212
Steve,

This will get you the weeknumber of a given date:

= format (#1/1/2012#,"w")

...
But there are other ways to get 52 consecutive numbers through code...
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38729218
Your syntax will also work with a slight modification:

= DatePart("ww",#01/01/2012#)

Open in new window



(You were mis-using the Date function - which simply returns todays date)
0
 
LVL 39

Expert Comment

by:als315
ID: 38729238
I don't understand why you can't assign number without any conversions?
=1, =2 etc.
If it is detail part of your report, you can create table with numbers from one to 52 and use it in your report.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38729243
Steve,

I'm glad that helped out - but I'm still not clear what you are trying to accomplish.

If those values really need to be set dynamically, my own approach would have been to look at them simply as "52 consecutive numbers" rather than anything date-related.

I'd name the textboxes (or labels) in a sequential manner like txtWk01, txtWk02, etc.  They could then be populated with code in the Open Event of your form like this:

Private Sub Form_Open(Cancel as integer)
For i = 1 to 52
       Me.Controls("txtWk" & format(i,"00")) = i
next
End Sub

Open in new window

0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38729248
I need a calculated value is because I'm going to use that value in a formula in another textbox to the right of each week's number textbox.
This doesn't really make sense.  You are using calculated values just to return the numbers 1 through 52 to use in another calculated textbox?
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Input box criteria 3 20
Dealing with Null in VBA sql statement 9 25
Resize text 4 16
Filtered index 5 4
This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now