• DoCmd.OpenQuery

    Author
    Topic
    #458057

    I can do this for a form:

    DoCmd.OpenForm FormName:=”frm_Show Master”, WhereCondition:=”[ShowNo]=1″, Windowmode:=acWindowNormal

    I can do this for a report:

    DoCmd.OpenReport ReportName:=”rpt Show Master”, WhereCondition:=”[ShowNo]=1″, View:=acPreview

    I can do this for a query:

    DoCmd.OpenQuery “qry Show Master – 1”, acNormal, acEdit

    where [ShowNo] =1

    Is there a way of doing:

    DoCmd.OpenQuery “qry Show Master” and set the WhereCondition

    Thanks in advance for any help with this

    Viewing 0 reply threads
    Author
    Replies
    • #1150412

      You can’t add a where condition for the instruction DoCmd.OpenQuery.

      The only way to do this is write code to modify the SQL of the query .

      • #1150421

        Thanks Francois,

        Some day in my spare time, I’ll learn how to code SQL

        • #1150463

          Many of us learn by using the Query Builder and then looking at the SQL it creates. The next step is to create a SQL string in VBA, and concatenate and Where conditions at the appropriate points. Then you check it by stepping to the point where the SQL string has been built and do a debug print. Then copy that and paste it into a new query in SQL view and see if it behaves. Or you can sit and read a book….

    Viewing 0 reply threads
    Reply To: DoCmd.OpenQuery

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: