How open forms using certain criteria

Posted on 2011-10-11
Last Modified: 2013-11-05
I have a command button on a form which when clicked I want to have a second form open to display only certain records.  Here is my code which is not working.

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmPrintOrdTranx"
    DoCmd.OpenForm stDocName, acNormal, , [Type] = "P", acFormEdit, acWindowNormal

Can some please help?
Question by:SteveL13
    LVL 47

    Accepted Solution


        DoCmd.OpenForm stDocName, acNormal, , "[Type] = 'P'", acFormEdit, acWindowNormal

    Note that the P is wrapped with single quotes and the entire WHERE condition is wrapped in quotes.

    LVL 17

    Expert Comment

    by:Barry Cunney
    Hi Steve,
    Try this
    DoCmd.OpenForm stDocName, acNormal, , "[Type] = 'P'", acFormEdit, acWindowNormal

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
    I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now