Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    edg is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    14

    Form filter value to Report not working

    I am using a form to select a filter value to open a report. The report data source is a query listing rooms and their uses (office, storage, etc.). The usage table key is “RmUseID” and the literal is “RmUse” and is part of the query that builds the report.
    The form uses a combo box based on a query using “RmUseID” and “RmUse” – the bound column is “RmUseID”.
    The form button click event has the following code:



    Private Sub RmUseSelect_Click()

    If IsNull(RmUseID) Then
    MsgBox "Please Select a Room Use"
    Else
    Dim filter
    filter = "[RmUseID] ='" & RmUseID & "'"
    DoCmd.OpenReport "mhc filtrmr", acViewPreview, filter

    End If
    End Sub

    The query in the report has in the ‘criteria’ row under the “RmUseID” - [forms]![mainswitchbdf]![rmuseid].

    When I click the form button, I get a ‘parameter needed’ pop-up – if I put a RmUseID in, the report opens showing the filtered data. If I scroll over ‘filter’ in the docmd in the form when debugging, I see the correct RmUseID is there. But it is not being passed to the report or is not being recognized by the report.

    And if I open up the report alone, I get the parameter popup – entering a valid RmUseID gives me a correct filtered report. I’ve checked field names, spelling, syntax – I’m at a loss.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Is RmUseID a number type field? If it is, remove the apostrophe delimiters. Those are for text type field parameters. Actually, would not expect the popup, would expect error message.

    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.

  3. #3
    edg is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    14
    Yes it is a number field - will try it.

  4. #4
    edg is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    14
    I just removed the ' apostrophes - code is now:

    filter = "[rmuseid]=" & RmUseID & "" - still didn't work - getting parameter popup.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Just hit me, you have dynamic parameter in query and VBA code building filter. Don't do both. I never use dynamic parameters in query, I use VBA.

    Don't need the second ""

    Try:
    filter = "[rmuseid]=" & Me.RmUseID

    or

    DoCmd.OpenReport "mhc filtrmr", acViewPreview, "[rmuseid]=" & Me.RmUseID
    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
    edg is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    14
    It didn't work. I am leaving work shortly but will compact db and forward tomorrow. Thanks!

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The filter is in wrong argument. Use WhereCondition argument. I have never used the FilterName argument. Missing a comma:

    DoCmd.OpenReport "mhc filtrmr", acViewPreview, , filter
    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
    edg is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    14

    db attached

    MHC.accdb OK - back to work - here is my db.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    You have not incorporated the suggestion to eliminate the parameter from query (post 5). BTW, the parameter has spelling error anyway. ([orms]![mainswitchbdf]![rmuseid])

    Your code does not incorporate the last suggested correction (post 7).
    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.

  10. #10
    edg is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    14
    Sorry about that - I packed the db after I got your first suggestions, not the later ones. I do have some work to do and will update you. I appreciate your time.

  11. #11
    edg is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    14
    MHC1.accdbI apologize for the errors on the last posting and my response delay - I'm responsible for a 100 bed retirement facility and we had a state inspection for the past day (unscheduled). I made the changes as you suggested but the parameter pop-up still comes up.

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The report RecordSource sql still has the dynamic parameter.
    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.

  13. #13
    edg is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    14
    Please help me here - dynamic parameter - are you saying drop the forms! in the criteria under rmuseid?

  14. #14
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Yes. Remove the dynamic criteria from the RecordSource sql. It is not necessary. The VBA code is applying this filter criteria.
    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.

  15. #15
    edg is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    14
    It worked! Thank you so much for your, time, patience and expertise. I did all kinds of things with Access around 2001, but haven't touched any programing since! Boy you really forget stuff if you don't use it. Again, many thanks! Not sure - does this thread need to be 'closed out' - who does it?

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Re-Filter report within form
    By bikeordie1 in forum Access
    Replies: 2
    Last Post: 04-02-2013, 08:14 AM
  2. Form filter not working
    By workuser in forum Forms
    Replies: 4
    Last Post: 02-04-2013, 02:48 AM
  3. Open Report Filter Stopped Working
    By ggs in forum Reports
    Replies: 5
    Last Post: 09-27-2011, 05:05 AM
  4. Replies: 2
    Last Post: 08-18-2011, 10:20 PM
  5. Filter By Form not working!
    By Freybourne in forum Access
    Replies: 6
    Last Post: 06-22-2010, 09:41 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