Results 1 to 5 of 5
  1. #1
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Open Report From Form Link By CustomerID Not Showing Data

    I have a Customers form with a subform on it to show the order details for that Customer.
    I would like for the user to be able to open a report from that form and view the results of that customer order.
    I have a Report based on the same recordsource as the subform and a command button on the Customer form to open the Report.

    If I open the Report NOT using the form command button, it shows the data fine. If I open it using the command button I get NO data.
    Here is my code for the command button.The subform is linked by CustomerID
    Attached is pics of Report and also query it is based on.Plus command button code.



    On Error GoTo Err_Command55_Click
    Dim strReportName As String
    Dim strCriteria As String

    strReportName = "CustomerOrders"
    strCriteria = "[CustomerID]" = " & Me![CustomerID] & " '"
    DoCmd.OpenReport strReportName, acViewPreview, , strCriteria

    Exit_Command55_Click:
    Exit Sub

    Err_Command55_Click:


    MsgBox Err.Description
    Resume Exit_Command55_Click
    Attached Thumbnails Attached Thumbnails OrdersSummaryReport.jpg   OrdersSummary.jpg  

  2. #2
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    It looks like you have a stray single-quote in there. Try removing the part hilighted in red and see if that fixes the problem.

    Code:
       On Error GoTo Err_Command55_Click
       Dim strReportName As String
       Dim strCriteria As String
        
       strReportName = "CustomerOrders"
       strCriteria = "[CustomerID]" = " & Me![CustomerID] & " '"
       DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
      
    Exit_Command55_Click:
        Exit Sub
    
    Err_Command55_Click:
        MsgBox Err.Description
        Resume Exit_Command55_Click

  3. #3
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Nope, tried removing all that, no change

  4. #4
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Whoops! It looks like there was an extra double-quote right after [CustomerID] as well. In fact, with the placement of that one, you should have been getting a compile error too.

    Here, try this:
    Code:
        On Error GoTo Err_Command55_Click
        Dim strReportName As String
        Dim strCriteria As String
    
        strReportName = "CustomerOrders"
        strCriteria = "[CustomerID] = " & Me![CustomerID]
        DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
    
    Exit_Command55_Click:
        Exit Sub
    
    Err_Command55_Click:
        MsgBox Err.Description
        Resume Exit_Command55_Click

  5. #5
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Yep, that did the trick.

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

Similar Threads

  1. Replies: 1
    Last Post: 12-04-2012, 07:08 PM
  2. Duplicate data not showing in report
    By ashu.doc in forum Reports
    Replies: 2
    Last Post: 09-19-2012, 05:56 AM
  3. Open report from data entry form
    By pbuecken in forum Forms
    Replies: 5
    Last Post: 01-14-2012, 12:07 PM
  4. Replies: 0
    Last Post: 03-07-2011, 04:30 PM
  5. Replies: 2
    Last Post: 04-29-2009, 11:50 AM

Tags for this Thread

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