Results 1 to 6 of 6
  1. #1
    Kimbertha is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Sep 2010
    Posts
    33

    More dynamic reporting questions.

    Greetings Everyone!

    I have a crosstab query that displays years 2000 to 2010 across the top. I have a basic report that works well and is aesthetically pleasing, however I am struggling with two questions about the design.

    Question 1
    This year the crosstab query will display years 2000 to 2010. Next year it will display 2001 to 2011. Is there a way for the report to dynamically capture and display the change in years as the oldest year drops off and a new year is added? Otherwise I would have to manually update the field names in the report each year, which would be a bummer.

    Question 2
    Is there a way to perform rounding calculations within the detail fields? I am familiar with how to create an "unbound" box and use formulas there. But if I place a calculation directly in a detail report, I get a circular reference error, which makes sense I guess, because a field cannot calculate its own value. I am reluctant to replace all my detail fields with unbound fields only because I have done a lot of work formatting the detail fields, getting their placement just right, etc.

    Any suggestions would be great. Thank you for reading.



    Kim

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    My guess to question 1 is yes but we need more minformation for a more specific answer. As for question 2: are you aware you can have invisible controls on your report for such operations?

  3. #3
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    I don't know how to deal with Q1.

    For Q2, can you just format the bounded textbox?

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by Kimbertha View Post
    if I place a calculation directly in a detail report, I get a circular reference error
    Kim,

    I believe a circular reference error can also be caused by either the same control source for two controls or the same name for two controls. Dont' quote me though...Access usually stops you from exiting the 'name' field of a control if it's duplicated after typing it in...

  5. #5
    Kimbertha is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Sep 2010
    Posts
    33
    Update!

    I fixed my second question (see below) by rewriting the report detail and totals section. It was painful because the computer I have at this client is s l o w . But that part is working.

    Question 2
    Is there a way to perform rounding calculations within the detail fields? I am familiar with how to create an "unbound" box and use formulas there. But if I place a calculation directly in a detail report, I get a circular reference error, which makes sense I guess, because a field cannot calculate its own value. I am reluctant to replace all my detail fields with unbound fields only because I have done a lot of work formatting the detail fields, getting their placement just right, etc.

    But for my first question (see below), I am stumped. If there is not a direct solution, there must be a workaround . . .

    Question 1
    This year the crosstab query will display years 2000 to 2010. Next year it will display 2001 to 2011. Is there a way for the report to dynamically capture and display the change in years as the oldest year drops off and a new year is added? Otherwise I would have to manually update the field names in the report each year, which would be a bummer.





  6. #6
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    if I were you, I won't put so much effort into such once a year thing. I would just modify it every year, better than thinking hard to get lot of code - easy to cause problem - to perform the changes.

    If you still want to do it, following may help:

    1 Name the textboxes in the report in order: tb1, tb2, tb3...
    2 Name the label accordingly to: label1, label2, label3...
    3 In the open event of the report, make up the record source statement
    4 In the detail format event of the report, change the caption of each label.

    Sample code as following:
    Code:
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    ' modify captions
    'QryFlex is the cross tab query name
       Dim rs As dao.Recordset
        Dim col As Long
        Set rs = CurrentDb.OpenRecordset("select * from QryFlex where false")
        For col = 0 To rs.Fields.Count - 1
           Me.Controls("Label" & col).Caption = rs.Fields(col).Name
        Next
        Set rs = Nothing
    End Sub
    Private Sub Report_Open(Cancel As Integer)
    'change record source
        Dim rs As dao.Recordset
        Dim col As Long
        Dim source As String
        Set rs = CurrentDb.OpenRecordset("select * from QryFlex where false")
        source = "select "
        For col = 0 To rs.Fields.Count - 1
            source = source & "[" & rs.Fields(col).Name & "] as tb" & col & ","
        Next
        Set rs = Nothing
        source = Left(source, Len(source) - 1) & " from qryflex"
        Me.RecordSource = source
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Thoughts on Dynamic Reporting
    By swalsh84 in forum Reports
    Replies: 2
    Last Post: 09-24-2010, 12:27 PM
  2. Exception Reporting
    By shexe in forum Queries
    Replies: 16
    Last Post: 09-09-2010, 09:14 AM
  3. Reporting Issue
    By watzmann in forum Access
    Replies: 1
    Last Post: 08-30-2010, 08:16 PM
  4. Question on Reporting
    By jbarrum in forum Access
    Replies: 20
    Last Post: 01-14-2010, 02:05 PM
  5. Dynamic reporting
    By pushpm in forum Programming
    Replies: 0
    Last Post: 04-22-2009, 12:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums