Results 1 to 3 of 3
  1. #1
    bell is offline Advanced Beginner
    Windows 7 64bit Access 2002
    Join Date
    Feb 2015
    Posts
    37

    Question Generating a Report with only one record from a Form that has a subform

    Hi all,

    I fairly new to Access so bare with me...

    I am creating a data base that has two tables.
    Table one is called Route Sheet and has a Primary key "Part Number"
    Table two is called Operation Info and has two keys "Part Number" and "Operation Number"
    The relationship is one to many --> "One" Part Number in Route Sheet to "Many" Part Numbers in Operation Info



    I have a form called "Route Sheet Form" that has data entry stuff for all the fields in Route Sheet Table AND has a subform called "Operation Info subform" that displays all the fields in Operation Info Table for the particular part number selected.

    I want to add a print button to the form to print only one record (the record that is currently selected) at a time. I created a Report from my "Route Sheet Form" and called it "Route Sheet Report"

    I have looked over this website http://support.microsoft.com/kb/209560
    I added a command button for printing to a report, and wrote the following for the On Click event
    Code:
    Private Sub Print_Report_Click()
    
        Dim strReportName As String
        Dim strCriteria As String
        
        strReportName = "Route Sheet Report"
        strCriteria = "[Part Number]=" & Me![Part Number]
        DoCmd.OpenReport strReportName, acViewPreview, strCriteria
        
    End Sub
    But the button still reports everything, not the single Part Number
    Can anyone help me?

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Looks like you are missing a comma. There should be two commas between "acViewPreview" and "strCriteria"
    Try
    Code:
    DoCmd.OpenReport strReportName, acViewPreview, , strCriteria

  3. #3
    bell is offline Advanced Beginner
    Windows 7 64bit Access 2002
    Join Date
    Feb 2015
    Posts
    37
    Quote Originally Posted by ssanfu View Post
    Looks like you are missing a comma. There should be two commas between "acViewPreview" and "strCriteria"
    Try
    Code:
    DoCmd.OpenReport strReportName, acViewPreview, , strCriteria

    Hi thanks for your reply,

    I thought I had originally tried the code with the extra comma and I got an error so I took out the comma, but I just tried again with the extra comma and it now works...so I must have been doing something else wrong...

    Thanks again

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

Similar Threads

  1. Replies: 5
    Last Post: 08-25-2014, 05:33 PM
  2. Generating Report from Form filtering
    By oica72 in forum Reports
    Replies: 5
    Last Post: 12-17-2011, 05:35 PM
  3. Replies: 6
    Last Post: 08-22-2011, 06:52 PM
  4. Form using requerys and report generating
    By kroenc17 in forum Forms
    Replies: 1
    Last Post: 09-22-2010, 07:12 AM
  5. Generating Report from Form
    By mwabbe in forum Reports
    Replies: 8
    Last Post: 08-30-2010, 12:25 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