Results 1 to 11 of 11
  1. #1
    Mobile is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    11

    How to print only one record

    Hi I have been trying to print out only one record.



    My Primary key: Primary key (Auto Numbered)
    Form Name: Main Menu From2
    Button Name: Print Record
    Report Name: MOC Report1

    The Code is typed:
    Code:
    DoCmd.OpenReport "MOC Report1", acViewNormal, , "[Primary key] = " & Forms!MainMenuForm2


    When I created a button in the Form Design, I selected the "print record".
    I would appreciate anyone's help.
    Thank you!

  2. #2
    Mobile is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    11
    I also have tried this code below:

    Private Sub cmdPrint_Click()
    Dim strWhere As String

    If Me.Dirty Then 'Save any edits.
    Me.Dirty = False
    End If

    If Me.NewRecord Then 'Check there is a record to print
    MsgBox "Select a record to print"
    Else
    strWhere = "[Primary key] = " & Me.[Primary key]
    DoCmd.OpenReport "MOC Report1", acViewPreview, , strWhere
    End If
    End Sub


    But I'm getting this error massage:
    "Run-time error '2465': Management of change application can't find the field '/1' referred to in your expression"

  3. #3
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Mobile, what happens when you try to create your report?
    Do you get an error?

    DoCmd.OpenReport "MOC Report1", acViewNormal, , "[Primary key] = " & Forms!MainMenuForm2

    Forms!MainMenuForm2 needs the control that contains the ID (PK) to compare.

    Example; Forms!MainForm!ComboBox1

    Dale

  4. #4
    Mobile is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    11
    Hi Dale,

    Thank you for your response.
    I typed your code and gave me an error message:
    Compile error: Type mismatch


    I don't get error for the report part.

  5. #5
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Hi I have been trying to print out only one record.

    My Primary key: Primary key (Auto Numbered)
    Form Name: Main Menu From2
    Button Name: Print Record
    Report Name: MOC Report1
    Let's start from the beginning.

    No error.
    I am assuming that you want to create a report that contains information about the current record on a form.

    What happens when you try to create you report? I am assuming again that all records are returned.

    From where are you trying to select an ID to create the report?

    Dale

  6. #6
    Mobile is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    11
    by ID, do you mean Field Name from the table?

  7. #7
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    ID usually means the PK or auotnumber of the record.

    Dale

  8. #8
    Mobile is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    11
    the Record is identified by Primary Key with autonumber.
    Am I understanding correctly??

  9. #9
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Yes you are.
    Now Let's start from the beginning.

    No error.
    I am assuming that you want to create a report that contains information about the current record on a form.

    What happens when you try to create you report? I am assuming again that all records are returned.

    From where are you trying to select an ID to create the report?

    Dale

  10. #10
    Mobile is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    11
    I created "MOC Report1" and connected the information by using "Add Existing Fields" icon.
    When I type information into the Form, it will appear to the Report also.

  11. #11
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    On your form, you need to have the ID of the record(s) you want to have on the report.
    We need someway of identifying the record(s) for the report.

    Can you upload the database?

    Dale

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

Similar Threads

  1. Print ONE record from a form, not all of them
    By jparker1954 in forum Programming
    Replies: 9
    Last Post: 12-06-2011, 11:43 AM
  2. Replies: 5
    Last Post: 10-26-2011, 02:59 PM
  3. Print a specific record
    By NISMOJim in forum Forms
    Replies: 5
    Last Post: 01-28-2011, 04:32 PM
  4. Print Single Record
    By stattech in forum Reports
    Replies: 5
    Last Post: 10-05-2010, 03:38 AM
  5. Print a different image per record
    By mcaldwell in forum Reports
    Replies: 5
    Last Post: 04-24-2009, 02:00 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