Results 1 to 12 of 12
  1. #1
    Farida is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    19

    Populate Text box in Repoprt depending on value entered in Parameter

    Hi, I have the Form with details below.
    Form name - [MOC Creation Stats]
    Query used in the form - [CREATED_STATISTICS]


    Parameter name - [MOC Number Starts With]
    Query -
    PARAMETERS [MOC Number Starts With] Text ( 255 );
    TRANSFORM Count(MonthName(Month([CREATED DATE]))) AS ['NUMBER']
    SELECT MonthName(Month([CREATED DATE])) AS ['MONTH'], Count(MOC_DATA.[MOC NUMBER]) AS [Total Of MOC_NUMBER]
    FROM MOC_DATA
    WHERE (((MOC_DATA.[MOC NUMBER]) Like "*" & [MOC Number Starts With] & "*"))
    GROUP BY MonthName(Month([CREATED DATE])), Month([CREATED DATE])
    ORDER BY Month([CREATED DATE])
    PIVOT MOC_DATA.ASSET;

    When the report is loaded, it asks for Paramater value MOC number stats with :

    I want to populate the textbox as below
    If value entered is CR12 - then 2012
    If value entered is CR13 - then 2013
    If value entered is CR14 - then 2014
    If value entered is blank - overall

    Please advise.
    ----------------------
    My tries as below.
    1. Set
    Control Source of textbox to =[Reports]![MOC CREATION STATS]![MOC Number Starts With].

    this doesnt work. In turn i get
    #Name? in my textbox.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Try just:

    =[MOC Number Starts With]
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Farida is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    19
    No, this doesnt work. I am getting the same error #Name? in the textbox

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Farida is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    19
    How can i do this? Its a big database.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    You could export that report, query and table to a db, then zip it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Farida is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    19

    Zip file of dbase

    Quote Originally Posted by pbaldy View Post
    You could export that report, query and table to a db, then zip it.
    hERE'S my zipped file. I have many queries here.
    Attached Files Attached Files

  8. #8
    Farida is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    19
    Question one - I have created a parameter form YEAR_FORM to accept value. But it does not get called. I referred to https://support.office.com/en-nz/art...bmform_param_1 to do so.
    Question two - Secondly i want to populate the YEAR in the header of the report based on the value entered in the YEAR_FORM
    Question three - The Parameter prompts twice for printing the report. How can i avoid this?
    Question Four - I get below error while report generation for the year 2011. This is because this created records only from June month onwards. How can i rectify this?
    Microsoft Access database engine does not recognize " as valid field name or expression

    Your expertise solutions are much appericiated. Thanks.

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    To the original question, you seem to be using a form now, and you have the wrong reference. It should be:

    =[Forms]![YEAR_FORM]![YEAR_COMBO]

    I'll try to look at the others later, must eat breakfast now before I get cranky.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Regarding other questions:

    3) I don't get prompted when the report opens, as long as the form is open.
    4) I don't do much charting, but the crosstab query returns fewer column for 2011. Something in the report is looking for columns that don't exist, and needs to be adjusted to be more dynamic. I may be able to look at it later. Don't see where it is right off, but my lack of chart knowledge is probably getting in the way.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    Farida is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    19
    Thanks for your responses Paul. I am still looking for an answer to my below query. Yes the result here is generated from the month of June rather than January and that i causing the error message to pop up. Can you please provide a solution to this. Thanks.

    Question Four - I get below error while report generation for the year 2011. This is because this created records only from June month onwards. How can i rectify this?

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Could change the combobox RowSource to an SQL statement:

    SELECT DISTINCT Year([Created Date]) FROM MOC_Data;

    I am not getting any error message for the report for any year selected. However, 2011 data doesn't display in the chart, it shows 2012 data. I don't understand why 2011 data won't display. The CROSSTAB query works.

    I have never seen apostrophe used as part of a field name. Is this because Month and Number are reserved words? Would be better to use something else for names.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 1
    Last Post: 08-05-2014, 12:40 PM
  2. Replies: 9
    Last Post: 06-20-2014, 12:27 PM
  3. Replies: 5
    Last Post: 01-10-2013, 11:38 AM
  4. Replies: 4
    Last Post: 04-26-2012, 09:46 AM
  5. Replies: 6
    Last Post: 06-09-2011, 03:41 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