Results 1 to 11 of 11
  1. #1
    Huddle is offline Competent Performer
    Windows XP Access 2010 64bit
    Join Date
    Jun 2010
    Posts
    318

    Troubleshoot Command Button that is Filtering the Form it is Opening

    I have a command button that opens a form. When it opens it is in filter mode even though the properties indicate no filter on load.



    The command button is located on a tab, which I don't know that this should make a difference. I've looked in other places to see if any properties are set with a filter but I don't find any.

    Any guess as to why it would be doing this?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    What is the code behind the button?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Huddle is offline Competent Performer
    Windows XP Access 2010 64bit
    Join Date
    Jun 2010
    Posts
    318
    Private Sub ProjDetailCom_Click()
    On Error GoTo Err_ProjDetailCom_Click
    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "SubForm_CM_Package"

    stLinkCriteria = "[PK_Project_Num]=" & "'" & Me![PK_Project_Num] & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Exit_ProjDetailCom_Click:
    Exit Sub
    Err_ProjDetailCom_Click:
    MsgBox Err.Description
    Resume Exit_ProjDetailCom_Click

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    There you go. It's doing this:

    BaldyWeb wherecondition
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Huddle is offline Competent Performer
    Windows XP Access 2010 64bit
    Join Date
    Jun 2010
    Posts
    318
    I changed the code but am still getting the filter.


    Private Sub ProjDetailCom_Click()
    On Error GoTo Err_ProjDetailCom_Click
    DoCmd.OpenForm "SubForm_CM_Package", , , "PK_Project_Num = '" & Me.PK_Project_Num & "'"
    Exit_ProjDetailCom_Click:
    Exit Sub
    Err_ProjDetailCom_Click:
    MsgBox Err.Description
    Resume Exit_ProjDetailCom_Click

    End Sub

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You've simply eliminated the variable. If you don't want a filter:

    DoCmd.OpenForm "SubForm_CM_Package"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Huddle is offline Competent Performer
    Windows XP Access 2010 64bit
    Join Date
    Jun 2010
    Posts
    318
    I guess I should clearify. I want it to open to a specific record, PK_Project_Num, but when it is filtered it is only bringing up a blank form. When I unfilter it it brings up the document.....light bulb.... I only have one record in there. It is bringing up all records when I unfilter it. For some reason it is not filtering to bring up the correct record.....ummm. Need to figure out why it isn't reading the variable.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Is the record saved at the point the code runs? Have you set a breakpoint and checked the value when the code runs?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Huddle is offline Competent Performer
    Windows XP Access 2010 64bit
    Join Date
    Jun 2010
    Posts
    318
    I'm going to have to redo how I'm doing this. It isn't going to work with multiple projects. Thanks for your help though. Sorry to waste your time.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    always404 is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2013
    Posts
    19
    Why not just set the filter to nothing right after opening it.
    Like this:

    Me.Filter = ""

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

Similar Threads

  1. Opening a report from a form command
    By undee69 in forum Reports
    Replies: 4
    Last Post: 01-13-2013, 08:57 AM
  2. Replies: 15
    Last Post: 04-17-2012, 01:42 PM
  3. Opening new Tab with command button
    By JFo in forum Access
    Replies: 2
    Last Post: 09-12-2011, 01:45 AM
  4. Replies: 1
    Last Post: 07-27-2010, 02:27 PM
  5. Automatic Filtering when Opening form
    By Karyn-2000 in forum Forms
    Replies: 1
    Last Post: 12-03-2005, 09:29 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