Page 1 of 2 12 LastLast
Results 1 to 15 of 29
  1. #1
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132

    Printing a single record in a report

    I have a report (MatchesYPRep).It is based upon a query (YPMatchQAllMatches).

    I have a form (OrgReportF) that gives the details of an organization.
    It is based upon a table (OrganizationsT).

    The report (MatchesYPRep) has a button (ButtonPrintOrgForm) beside each entry. The button opens OrgReportF. The button is placed next to the OrgName field on the report.

    When the user presses the button, I want it to display the OrgReportF only for the record the button accompanies.

    So, for example, MatchesYPRep report looks like this:

    Kim Martin (Note: the report is grouped by a person associated with each org)
    AISEC [Print Org Report]
    Humane Society [Print Org Report]


    What I'm getting is an "Enter Parameter Value" box asking for YPMatchQAllMatches!OrgName.

    The macro behind the button is currently as follows:

    OpenForm

    Form Name: OrgReportF
    View: Form


    Filter name: [Blank]
    Where Condition = [OrganizationsT]![OrgName]=[YPMatchQAllMatches]![OrgName]

    If I I delete the text above in red, so the condition is [OrganizationsT]![OrgName]=[OrgName], I get a Ryn0tie error '2105' - "You can't go to the specified record." The debugging shows that it wants to go to a new record: DoCmd.GoToRecord , , acNewRec.

    Maybe something needs to go in the filter, but I didn't have any clue of what to put there.

    Any thoughts?

    Thanks so much!

    --ak

  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,518
    That should be a form reference, not a query. You're telling Access where to find the value to filter on. In VBA it looks like:

    BaldyWeb wherecondition

    In a macro, you need the full form reference:

    Forms!FormName.ControlName
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132
    I tried the Forms! line in the macro, but I got a run-time error.

    So then I changed it to an event procedure and tried your first example at ayour link:
    DoCmd.OpenForm "SecondFormName", , , "FieldName = " & Me.ControlName
    as
    DoCmd.OpenForm "OrgReportF", , , "OrgName = " & Me.OrgName

    In this case I got a parameter error asking me to "Enter Parameter Value." The box actually gives the value of the OrgName beside the button, but it wants me to enter a parameter.

    Any further thoughts?

    Thanks!

    --ak

  4. #4
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132
    As a side note, when I press the button by the first Org, I get the parameter error mentioned above.

    If I press the button beside any subsequent orgs, I get a "Run-time error '3075' -- Syntax error (missing operator) in query expression 'OrgName = [Then it puts the OrgName that the button is beside].

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    That would imply that the field or control names is misspelled. The parameter prompt is Access telling you it can't find something you've referred to. By the way, if the field is text you need the other syntax.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132
    Thank you!

    I used your first format:

    DoCmd.OpenForm "SecondFormName", , , "FieldName = '" & Me.ControlName & "'"
    as
    DoCmd.OpenForm "OrgReportF", , , "OrgName = '" & Me.OrgName & "'"

    It appears to be getting closer!

    Now my results are as follows:

    If I press the button next to certain orgs, I get a filtered report with two records: (1) the one I want; and (2) a blank record. It lands on (2).

    If I press the button next to other orgs, I get only a single blank record.

    Does that ring any bells?

    Thanks again!

    --ak


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

  8. #8
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132
    It's uploaded at my 5:25 PM post today on this thread. Obviously, I have several issues!!

    https://www.accessforums.net/forms/q...tml#post138967

    As a side note, the query YPMatchQAllMatches has been renamed MatchQAllMatches.

    Thank you so much!

    --ak
    Attached Files Attached Files

  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,518
    It will have to wait until Monday, unless you can save it in 2007 format. My laptop with 2010 on it is at work.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132
    I can't access it until Monday myself! I appreciate the help! Have a great weekend!

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You have code in the form being opened that places it on a new record. The ones where you only get the blank don't have a record in that form's source.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132
    Quote Originally Posted by pbaldy View Post
    You have code in the form being opened that places it on a new record.
    Thank you!!!

    I really appreciate your being able to see what was wrong!

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No problem!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132
    Marked solved!

  15. #15
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132
    Hi, pkbaldy!

    I've made a bit of a change to my database. I made my OrgReport into an actual report, rather than a form, because it allows me to display the contacts better.

    The original idea was to press a button (ButtonOpenOrgReport) beside an field housing an organization (OrgName), both located in the detail portion of a report (EngageAllYPRep). That button would display another report (OrgReport), but only for the organization it is next to on the report. The field name is OrgName in both cases.

    Here's the code I currently have:

    Private Sub ButtonOpenOrgReport_Click()
    DoCmd.OpenReport "OrgReport", , , "OrgName = '" & Me.OrgName & "'"
    End Sub

    What it does is attempt to PRINT the OrgReport (rather than open it).
    Sometimes, it gives me the correct report, but it is followed by a blank page -- and I don't have a "New record on open" command.
    Sometimes, it gives me a blank report (with only the hard form text, and no field info), also followed by a blank page.
    In any case, it prints, rather than opens the form.

    Do you have any thoughts?

    Thank you so much!

    --ak

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. What am I doing wrong? Printing a single report
    By sofarfromexpert in forum Reports
    Replies: 1
    Last Post: 07-15-2012, 07:33 PM
  2. Replies: 0
    Last Post: 05-25-2011, 06:13 AM
  3. Printing a single Report from two forms
    By cvolkers in forum Programming
    Replies: 4
    Last Post: 03-06-2011, 11:27 PM
  4. How to print a single Record's report?
    By yes sir in forum Access
    Replies: 7
    Last Post: 09-20-2010, 07:31 AM
  5. Printing a single report from form
    By OFA in forum Forms
    Replies: 9
    Last Post: 06-08-2010, 09:27 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