Results 1 to 8 of 8
  1. #1
    JustAsIAm is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    4

    Placing User-Defined Search Parameters in a Report Header

    Hello everybody,

    I created a Access 2010 database query to allow a user to search a list of orders between 2 dates, and I created a form for them to use for this search.

    Then I created a report for the search results to land on. What I want to do is have the 2 dates that the user provided be displayed in the header of the report.

    I created a new Text Box and placed it in the header. In place of the "Unbound" filler that was there, I placed

    "=[Forms]![frm_DateRange]![txtStart]".



    I used the following steps to do this:

    1. Clicked on the Text Box control
    2. Pressed the "Property Sheet" button
    3. Selected the "Data" Tab
    4. Pressed the "..." button next to the "Control Source Entry
    5. The "Expression Builder" came up
    6. Double-clicked on the database name in the "Expression Elements" window
    7. Double-clicked on "Forms", then double-clicked on "All Forms"
    8. Selected the rpt_DateRange" form
    9. Selected "txtStart" from the "Expression Categories" window.
    10. I did not select anything in the "Expression Values" window.

    When I go to "Report View", and see the Text Box I added, but inside it, it just says "#Name?"

    Ideas?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    That looks like it would work. Try placing a new unbound text box in the header. Copy the text that is your expression and paste it inside your new control, replacing the word "Unbound" with the expression you posted here.

  3. #3
    JustAsIAm is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    4
    That is EXACTLY what I already did.

    For giggles, I just deleted the Text Box I have there and started from scratch. I get the same exact thing.

    Check out the attached images.
    Attached Thumbnails Attached Thumbnails GoodFood-2.PNG   GoodFood-1.PNG  

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Look at your form named "frm_DateRange". Look for the control named, "txtStart". Highlight this control and look at the property sheet. In the "Other" tab there is a field for "Name". Is the name of your control "txtStart"?

    The syntax for the fully qualified name of your control must be 100% correct. frm_DateRange must be the name of the form and the form must be open when the report opens. txtStart must be the name of the control and its value must be something other than Null (pretty sure Null will give you the #name thing).

    If these conditions are met, [Forms]![frm_DateRange]![txtStart] is the fully qualified name of the control AND the expression =[Forms]![frm_DateRange]![txtStart] should retrieve the value of the control from the control's Value property.

  5. #5
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    I created a new Text Box and placed it in the header. In place of the "Unbound" filler that was there, I placed
    "=[Forms]![frm_DateRange]![txtStart]".
    1. Double-clicked on "Forms", then double-clicked on "All Forms"
    2. Selected the rpt_DateRange" form
    check your form name .

  6. #6
    JustAsIAm is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    4
    OK ItsMe, you are right. My form name is correct, my control name is correct.

    When I run the report, it asks me for the beginning and ending dates and then gives me the #Name? problem.

    However, when I run the report using the frm_DateRange form, everything works perfectly. This must be (as you said) because at that point the form is open when the report is called.

    Thanks for the help.

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    If there is a variable you want to use globally you can declare it in a Standard module. Another approach is to pass variables via Open Args in a DoCmd.OpenReport statement.

    In other words, if the form is going to close before the report loads, you can store your variables in memory somewhere other than the form's memory.

  8. #8
    JustAsIAm is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    4
    I appreciate it. I am new to all of this. So far, I have a blank form that has a button that launches the Date Range form. That form calls the report in question.

    So far, it is working.

    Thank you

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

Similar Threads

  1. Replies: 13
    Last Post: 12-12-2013, 07:22 PM
  2. Replies: 3
    Last Post: 11-12-2013, 04:13 PM
  3. user-defined type not defined
    By markjkubicki in forum Programming
    Replies: 3
    Last Post: 05-09-2013, 05:15 PM
  4. Replies: 1
    Last Post: 12-14-2012, 12:32 AM
  5. Replies: 3
    Last Post: 04-07-2010, 11:25 AM

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