Help with VBA Code in Access 2010

Posted on 2012-08-29
Last Modified: 2012-08-29
Hi. I have following code below.  Purpose is to open the form "Financial-Table form-PO".  I would like to use as a filter (2 queries): "qryInputForm-CLOSED",
"qryInputForm-CLOSED-before conversion".

How can i modify below listed code?

I changed lines

stfilter="qryInputForm-CLOSED-before conversion"
 DoCmd.OpenForm stDocName, stfilter, , stLinkCriteria

However, I got an error "type mismatch"

Please see the code below (before adjustments)

Dim stDocName As String
    Dim stLinkCriteria As String
    Dim stfilter As String
    stDocName = "Financial-Table form-PO"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Open in new window

Question by:maximyshka
    LVL 13

    Accepted Solution

    The filter should be the third argument for DoCmd.OpenForm, not the second.

    The line should read:
    DoCmd.OpenForm stDocName, , stfilter, stLinkCriteria

    I would delete the stLinkCriteria if you're not using it.

    Also, you may need to enclose your query name in [ ] because of the space.
    stfilter="[qryInputForm-CLOSED-before conversion]"


    Author Closing Comment

    Thanks Lee

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    The first two articles in this short series — Using a Criteria Form to Filter Records ( and Building a Custom Filter ( — discuss in some detail how a form can be…
    Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

    737 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

    19 Experts available now in Live!

    Get 1:1 Help Now