Results 1 to 3 of 3
  1. #1
    drawc is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    2

    Print current record to a report

    Private Sub Command30_Click()
    DoCmd.RunCommand acCmdSaveRecord
    Dim strDocName As String


    Dim strWhere As String
    strDocName = "Civil Process"
    strWhere = "[FormID]=" & Me!FormID
    DoCmd.OpenReport strDocName, acPreview, , strWhere
    DoCmd.RunCommand acCmdPrint
    End Sub

    I can get this code to print only one record but then the button will always print this record. It will not change and print the current record.
    FormID is an autonumber to give each record it own id.

    Can anyone help out a "Work in Progress" learner?

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    This works for me.

    Code:
    Private Sub Command28_Click()
    On Error GoTo Err_Command28_Click
    
        Dim stDocName As String
    
        stDocName = "Submission"
        'DoCmd.OpenReport stDocName, acNormal, , "[ID] = Forms!frmClients!ID"
        DoCmd.OpenReport stDocName, acViewPreview, , "[ID]=Forms!frmClients!ID"
    
    Exit_Command28_Click:
        Exit Sub
    
    Err_Command28_Click:
        MsgBox Err.Description
        Resume Exit_Command28_Click
        
    End Sub
    Looks like the only real difference are the location of the quotes on the DoCmd line and I specify the form name versus using the me. function. If you want to use the me.form function, try adding a me.requery at the beginning to make sure that Access updates and clears old information.

  3. #3
    drawc is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    2

    This helped out the most


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

Similar Threads

  1. Email a report of the current record.
    By jonudden in forum Reports
    Replies: 4
    Last Post: 08-21-2023, 07:37 AM
  2. Print Report from Current Record
    By hnkford in forum Reports
    Replies: 15
    Last Post: 05-22-2015, 08:08 AM
  3. Replies: 5
    Last Post: 10-26-2011, 02:59 PM
  4. Report from current record
    By billgyrotech in forum Reports
    Replies: 18
    Last Post: 07-26-2011, 03:39 PM
  5. Show only current record in report from form/subform
    By stelioshania in forum Reports
    Replies: 0
    Last Post: 03-02-2011, 02:19 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