Results 1 to 6 of 6
  1. #1
    Historypaul is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    64

    Filtering report on OpenArgs - report asks for parameter for OpenArgs

    I have a button on a form that opens up the current record displayed on the form in a report. Or at least it should. When I click, it always asks me for the parameter value for OpenArgs.

    On the form I have:


    Code:
    Private Sub Command145_Click()
    DoCmd.OpenReport "Single_Incident_Report", acViewPreview, , , , ID
    End Sub
    On the report I have:
    Code:
    Private Sub Report_Load()
    Me.Filter = "([Incidents].[ID] = [OpenArgs])"
    Me.FilterOn = True
    End Sub

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I'll check but I believe the OpenArgs argument is the 7th parameter, not the 6th.

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Nope, I stand corrected, it is the 6th argument. Why not just use the WhereCondition argument? It is the 4th argument.
    DoCmd.OpenReport "Single_Incident_Report", acViewPreview, , "[ID] =" & Me.ID
    ...assumong this is a Numeric value. Otherwise if it is a string then you would need delimiters.
    DoCmd.OpenReport "Single_Incident_Report", acViewPreview, , "[ID] ='" & Me.ID & "'"

  4. #4
    Historypaul is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    64
    Code:
    DoCmd.OpenReport "Single_Incident_Report", acViewPreview, , "[ID] =" & Me.ID
    I used the code you recommended above. It gave me an error stating that ID could refer to more than one table in my select statement, so I changed it to what's shown below and it ended up working just fine... Thanks. I tried a million different ways for hours before finally being willing to post the question. I really preferred to use the Where property in the OpenReport command, but I had tried it a million ways earlier and it wasn't working.

    Code:
    DoCmd.OpenReport "Single_Incident_Report", acViewPreview, , "[Incidents].[ID] =" & Me.ID

  5. #5
    Historypaul is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    64
    Oh and THANK YOU!

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You are very welcome. Thanks for posting back with your solution.

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

Similar Threads

  1. How to set openargs of sub report?
    By flippedbeyond in forum Programming
    Replies: 11
    Last Post: 09-20-2011, 08:24 PM
  2. OpenArgs Problem: Error 438
    By SwaziMan in forum Programming
    Replies: 2
    Last Post: 08-05-2011, 12:20 PM
  3. Open a second form using the OpenArgs
    By blueraincoat in forum Forms
    Replies: 6
    Last Post: 06-02-2011, 06:19 AM
  4. Showing OpenArgs in a Report.
    By SIGMA248 in forum Programming
    Replies: 2
    Last Post: 04-01-2011, 11:57 AM
  5. Opening a form with openargs and things
    By mwabbe in forum Forms
    Replies: 5
    Last Post: 09-29-2010, 11:01 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