Results 1 to 10 of 10
  1. #1
    zmbaker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    31

    Open Report Form Button

    I am trying to add a button to my form that opens a report for the current record being shown on the form but I am having no such luck. Any Ideas on how to do this easily?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    What have you tried? Why doesn't it work - error message, wrong results, nothing happens?

    Something like:

    DoCmd.OpenReport "report name", , , "ID=" & Me.ID
    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.

  3. #3
    zmbaker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    31
    This is currently what I have and it just returns the report unfiltered

    OpenReport
    Report Name:PurchaseOrder
    View: Report
    Filter Name:
    Where Condition: "[TVCNo]=" & [Reports]![PurchaseOrder]![TVCNo]

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Turn the wizard on, (on the toolbox , push the magic wand in)
    grab a button, drag it to the form
    it will ask you questions..select reports, the pick your report.

    When its done you can look at the code behind the button.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Should reference the form, not report, as parameter: [Forms]!formname]!TVCNo

    Is TVCNo a number or text type field? If text, need apostrophe delimiters:

    Where Condition: "[TVCNo]='" & [Forms]!formname]!TVCNo & "'"
    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.

  6. #6
    zmbaker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    31
    That did not work, it still only populates all of the records on the report, rather than the current record.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    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.

  8. #8
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Posts
    528
    Private Sub cmdPrintPreview_Click()
    Dim strReportName As String
    Dim strCriteria As String
    If NewRecord Then
    MsgBox "aaaaaa." , vbInformation, "aaaaaa"
    Exit Sub
    Else
    strReportName = "RptInvoice"
    strCriteria = "[OrderDateID]= " & Me![OrderDateID]
    'strCriteria = "[lngSalespersonID]='" & Me![lngSalespersonID] & "'"
    DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
    End If
    End Sub

  9. #9
    zmbaker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    31

    Attached Database

    VSC Master Database.beta - Copy.zip

    I have attached the DB alot of information has been removed but i believe that form and report still work together, thanks for your help through this matter.

  10. #10
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Posts
    528
    OK
    Look at this
    Attached Files Attached Files

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

Similar Threads

  1. Replies: 3
    Last Post: 07-11-2013, 11:52 AM
  2. Replies: 2
    Last Post: 05-11-2012, 11:52 AM
  3. Open Current Report With Form Button
    By Rick5150 in forum Reports
    Replies: 8
    Last Post: 10-12-2011, 02:28 PM
  4. Button to open a Report
    By 95DSM in forum Reports
    Replies: 1
    Last Post: 07-09-2010, 11:11 AM
  5. Replies: 3
    Last Post: 01-14-2010, 08:32 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