Results 1 to 6 of 6
  1. #1
    treblak is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    8

    Question How to dynamically create header and data field in Report using the query output

    How to dynamically create header and data field in Report using the query output


    -------------------------------------------------------------------------------------------

    I got a query which displays data for 5 weeks. but currently i need to update the report header and the fields as the week get moved on. any solution to display the header and fields based on the query valuesClick image for larger version. 

Name:	msaccesserror.jpg 
Views:	18 
Size:	23.4 KB 
ID:	27538

    For my case the header and fields not refreshing to the new week

    I mean it works only for the particular week the next week onwards i need to update the fields manually inside the report.
    Last edited by treblak; 02-16-2017 at 06:20 PM. Reason: More info on the error

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    Choose generic names such as 'this year', 'last year', 'period1', etc so you do not have to keep modifying the headers and control sources in your report.

  3. #3
    treblak is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    8
    But the requirement is to display the header name with year-week eg 2017-07 2017-08 2017-09 2017-10 2017-11

    Is it possible to assign the fields on load

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    you will need vba code in the report load event to assign the control source of each control with the new field name. You will also no doubt need to also assign a new caption any associated labels

    depending on your naming convention, something like


    Code:
    dim I as integer
    for I=1 to 20
        me("fld" & I).controlsource=me.recordset.fields(I).name
        me("hdr" & I).controlsource=me.recordset.fields(I).name
    next i

  5. #5
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 8 Access 2013
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    I have an example on my site of how I handle this:

    Dynamic Report based on a Crosstab query

  6. #6
    treblak is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    8
    Thank you for the solution

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

Similar Threads

  1. Replies: 3
    Last Post: 05-17-2017, 07:41 AM
  2. Replies: 5
    Last Post: 09-12-2014, 06:41 AM
  3. Replies: 5
    Last Post: 12-23-2013, 04:29 PM
  4. Replies: 2
    Last Post: 03-18-2013, 03:03 PM
  5. Replies: 3
    Last Post: 02-17-2010, 02:29 PM

Tags for this Thread

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