Results 1 to 13 of 13
  1. #1
    Ryanm0085 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Feb 2015
    Posts
    22

    Single report for one record

    Hello. I have a very basic database that has pretty much everything i need in one table, which is entered by filling out a form. It is actually a call run report for my fire department. The issue i have now i i have about 3000 records compiled on one table and i need to print single incidents. When i try to print reports, it wants to print everything. I have searched high and low online and have found plenty of coding online, but nothing seems to work. My primary key is Case Number, which is a text input because of the format we required. The Form is Fire Call. The report i need it to print is Fire Report. If anyone can help, i would greatly appreciate it.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    but nothing seems to work
    please show us what you have tried.

    If you build a query to select only 1 record, and use that as the record source of the report, I think it should work.

  3. #3
    Ryanm0085 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Feb 2015
    Posts
    22
    This was code i found online,

    Private Sub cmdPrint_Click()
    'Print current record
    'using rptFire_Report.
    If IsNull(Me!Case_Number) Then
    MsgBox "Please select a valid record", _
    vbOKOnly, "Error"
    Exit Sub
    End If
    DoCmd.OpenReport "rptFire_Report", , , _
    "Case_Number = " & Me!Case_Number
    End Sub

  4. #4
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,412
    but nothing seems to work
    Do you get an error? What is it?
    Can you show us a typical Case_Number?

    Meanwhile, maybe
    Code:
    DoCmd.OpenReport "rptFire_Report", , , _
    "Case_Number = " & [Case_Number]

  5. #5
    Ryanm0085 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Feb 2015
    Posts
    22
    i put the button on the form page where the site told me to. When i push the button, absolutely nothing happens.

    The case numbers are the Primary Key, but I had to use text because of the format. Our case numbers would look like this: 18-001

  6. #6
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,412
    So the case_number is alphanumeric since it contains a non-numeric character.
    That fact has to be indicated to the criteria like this:

    DoCmd.OpenReport "rptFire_Report", , , _

    "Case_Number = '" & [Case_Number] & "'"

    Also, you need to be sure the button's event procedure points to the actual CmdPrint_Click code.

    Another tip:
    The code you are using will send the report directly to the Windows default printer.
    If you wish to see the report on the monitor first, use this:

    DoCmd.OpenReport "rptFire_Report", acViewPrintPreview, , _
    "Case_Number = '" & [Case_Number] & "'"


  7. #7
    Ryanm0085 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Feb 2015
    Posts
    22
    So i put in the data box of the button =[CmdPrint_Click]

    The error i get now is:The expression On Click you entered as the event property setting produced the following error: The object doesnt contain the automation object 'cmdPrint_Click.'.

  8. #8
    Ryanm0085 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Feb 2015
    Posts
    22
    This is the current code i am using:

    Private Sub cmdPrint_Click()
    'Print current record
    'using rptFire_Report.
    If IsNull(Me!Case_Number) Then
    MsgBox "Please select a valid record", _
    vbOKOnly, "Error"
    Exit Sub
    End If
    DoCmd.OpenReport "rptFire_Report", acViewPrintPreview, , _
    "Case_Number = '" & [Case_Number] & "'"
    End Sub

  9. #9
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,412
    Here's how to name the button and attach the code to it.
    This is the form in design view

    Click image for larger version. 

Name:	one.JPG 
Views:	18 
Size:	60.8 KB 
ID:	34679
    Also the form design view

    Click image for larger version. 

Name:	Two.JPG 
Views:	18 
Size:	60.6 KB 
ID:	34680

    And this is the code window (VB Editor). Click on the 3 dots beside "Event Procedure" above to see this

    Click image for larger version. 

Name:	Three.JPG 
Views:	19 
Size:	59.4 KB 
ID:	34681
    Now go back to the form and right click on it and select FORM VIEW
    Click on Print Report and you should see the report showing only the current Case_Number on the form.

  10. #10
    Ryanm0085 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Feb 2015
    Posts
    22
    I have that all. Unfortunately it still doesnt seem to work. Very frustrating

  11. #11
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,412
    Unfortunately it still doesnt seem to work.
    Can you post your DB for analysis?

  12. #12
    Ryanm0085 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Feb 2015
    Posts
    22
    I have attached the database. unfortunately i had to delete all the information. But basically the forms are used to fill out the tables. Nothing fancy. I am working on a report design that i would like to be able to print for single entries.

    Fire House - Copy.zipFire House - Copy.zip

  13. #13
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,412
    Your design of including all the members in each table is not the way to go.
    See the attached. I've set up the Drills as a many-to-many situation between members and drills. Requires adding a junction table, tblDrillMember.
    I've made a new form for Drills that has 2 side-by-side listboxes that allow you to see available members in the left listbox and attending members in the right listbox.
    You can move the members between them to show who attended the drill.

    You can replicate this for the other actions, extra credit, fires, etc.

    I am working on a report design that i would like to be able to print for single entries.
    What does this mean, a single member, or a single event like a drill?

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

Similar Threads

  1. Print Report for Single Record
    By Ryanm0085 in forum Reports
    Replies: 13
    Last Post: 05-03-2017, 08:33 AM
  2. Print out single record onto a report
    By CQCDave in forum Access
    Replies: 2
    Last Post: 04-23-2015, 06:54 AM
  3. Print out single record onto a report
    By CQCDave in forum Access
    Replies: 14
    Last Post: 01-08-2015, 12:55 PM
  4. Email a single record report
    By andrewhoddie in forum Macros
    Replies: 4
    Last Post: 11-10-2014, 03:31 PM
  5. Printing a single record in a report
    By kelann in forum Reports
    Replies: 28
    Last Post: 10-04-2012, 10:07 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