Results 1 to 15 of 15
  1. #1
    CQCDave is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    47

    Print out single record onto a report

    I have a form NoWorkOrder, i have attached a command button to Print Report. The report is named No Work Order. When i'm viewing that a record in Form View and click the command button i want only that record to print out onto the report.
    I'm using Ms Access 2010. Thanks for the assistance.

  2. #2
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    So what's your problem, you're not too clear?

    Are all your records printing out, are no records printing out, is anything happening unusual?

  3. #3
    CQCDave is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    47
    Yes, sorry Now all records print out when i click the Run Reports button.

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    You use the Criteria parameter in the DoCmd.OpenReport command.

    DoCmd.OpenReport "No Work Order", acViewNormal, , WhereCondition

    where WhereCondition is a string that uniquely identifies the record you want to print. It looks like a SQL where clause without the WHERE.

    for example: DoCmd.OpenReport "No Work Order", acViewNormal, , "Id = " & me![Record_Number]



  5. #5
    CQCDave is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    47
    Still having issues.... This is what i have;

    Dim strDocName As String
    Dim strWhere As String
    strDocName = "NoWorkOrder"
    strWhere = "[ID]=" & Me!ID
    DoCmd.OpenReport strDocName, acPreview, , strWhere

    It does prompt me to enter the ID but still prints out both records in the form ( only have 2 in the test database)

    Thanks for the help...

  6. #6
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    It prompts you to enter the ID? It shouldn't, at least not from anything in the code. Is [ID] the right name of the field in the table/query the report is based on (the prompts suggests it is not)?

  7. #7
    CQCDave is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    47
    Yes, ID is the correct field.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    If the report RecordSource is a query, post the SQL statement.
    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.

  9. #9
    CQCDave is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    47
    I have "On Click" it runs the following;

    Dim strDocName As String
    Dim strWhere As String
    strDocName = "NoWorkOrder"
    strWhere = "[ID]=" & Me!ID
    DoCmd.OpenReport strDocName, acPreview, , strWhere



  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    You already told us that.

    Asked for the report RecordSource sql statement.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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.

  11. #11
    CQCDave is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    47
    Here is a link to the database, Once opened click on Bracketry Data tab, then Open No Work Order Form.

    https://app.box.com/s/19kll6hm1abky7sw9ijw

    Thanks for your help,let me know if there is anything else you need.

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Couldn't download. Maybe this weekend I will be able to use faster internet.

    Otherwise, reduce file size (make copy and delete records and/or other stuff not relevant to the issue) and attach to post.
    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.

  13. #13
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    I got the download. The problem is as I thought - the ID field. Your report NoWorkOrder has a query (SQL) as its recordsource, but that query does not include the ID field from the NoWorkOrder table, and as a result the criteria in the Docmd.Openreport cannot find it and treats it as a parameter.

    Add the ID field to the report's recordsource and it should work fine.

  14. #14
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    As I suspected as well, which is why I asked for the SQL statement to be posted for review.
    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.

  15. #15
    CQCDave is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    47
    That did it, thanks for the help.

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

Similar Threads

  1. Replies: 4
    Last Post: 06-27-2014, 08:02 AM
  2. Replies: 2
    Last Post: 02-08-2012, 01:03 PM
  3. Print Single Record
    By stattech in forum Reports
    Replies: 5
    Last Post: 10-05-2010, 03:38 AM
  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. Print Single Report
    By emkwan in forum Access
    Replies: 1
    Last Post: 01-29-2010, 11:19 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