Results 1 to 6 of 6
  1. #1
    RobLoughrey is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2017
    Posts
    2

    DoCmd.OpenForm based on a query with a parameter

    I want to make a button to open a particular set of records in a navigation subform. The Macro wasnt working for me and I think its because my where condition is too long. So I am trying VBA instead using DoCmd.OpenForm The VBA I am using (unsuccessfully) is
    Code:
    DoCmd.OpenForm frmRCRViewClaimEdits, acNormal, qADTeamSummaryBtn, "Team" & [Forms]![MainMenu]![btnManagersMenu].[Form]![NavigationSubform].[Form].[cmbTeam]
    I'm getting an error message saying I need a valid form argument. I'm a bit of a scrub at VBA so I'm fairly sure I've just done something dumb and I'm hoping one of you can set me straight.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,933
    Presume code is in button Click event on MainMenu.

    Not really clear to me what the form structure is.

    btnManagersMenu is a subform?

    Then you have a Navigation form on that subform?

    I've never used Navigation form. Review https://www.accessforums.net/showthread.php?t=32053
    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
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    The form name needs to be surrounded by quotes.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,933
    Good catch aytee.

    And I expect the FilterName argument parameter needs to be within quote marks as well. I have never used the FilterName argument
    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.

  5. #5
    RobLoughrey is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2017
    Posts
    2
    The Form is contained in a couple of Navigation Subforms. My MainMenu is a Navigation form, followed by two more. I'm pretty sure I have the pathing right because when I run the query from the navigation pane it gives me the exact records I'm looking for. If I run the query from a Macro Button I get a parameter window asking for the Team value. I made the quotation mark suggestion for the form name and that did get me past the error I mentioned in the OP. I still keep getting asked for the Team parameter. I've tried having all of the criteria for the query inside the query and just running
    Code:
    DoCmd.OpenForm "frmRCRViewClaimEdits", acNormal, qADTeamSummaryBtn
    but that returns all records - apparently ignoring all of the criteria set in the query.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,933
    Try not using the FilterName argument. As I said, I have NEVER used it.
    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.

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

Similar Threads

  1. Replies: 3
    Last Post: 10-27-2017, 04:10 AM
  2. Replies: 11
    Last Post: 08-22-2017, 05:50 PM
  3. DoCmd.OpenForm with 2 Where Conditions
    By CharissaBelle in forum Programming
    Replies: 3
    Last Post: 10-19-2016, 09:32 AM
  4. What actually happens at docmd.openform
    By Beorn in forum Programming
    Replies: 4
    Last Post: 01-05-2011, 02:19 PM
  5. DoCmd.OpenForm Modification
    By alsoto in forum Forms
    Replies: 6
    Last Post: 05-01-2009, 07:28 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