Trying to create a querydef in an access 2000 database with

Posted on 2005-05-10
Last Modified: 2008-02-26
    Dim acapp As New Access.Application
        Dim strName As String = "Query1"
        Dim strSQL As String = "SELECT Div, ReportDate, theDesc, Sum(Unit) AS SumOfUnit, Sum(Total) AS SumOfTotal " & _
        "FROM unionReconciliationPKMSWSSR_Report " & _
        "GROUP BY Div, ReportDate, theDesc " & _
        "HAVING (((ReportDate) Between #4/25/2005# And #5/1/2005#)) " & _
        "ORDER BY Div, ReportDate, theDesc;"

        Dim qdfTemp As DAO.QueryDef

        With acapp
            .OpenCurrentDatabase(cdir & "\WSSR_PKMS_Balancing.mdb")

            qdfTemp = DAO.Database.CreateQueryDef()

            qdfTemp.Name = strName
            qdfTemp.SQL = strSQL


            CreateNewQuery = qdfTemp

        End With

I am getting the following error:

reference to a non-shared member requires an object reference

Question by:dressman
    LVL 34

    Assisted Solution

    What is


    I do not recall it but, just from the code, it looks like it might be a member of acapp.  In which case it probably needs to be

    .CreateNewQuery = qdfTemp

    Just a guess.

    LVL 15

    Accepted Solution

    What line is giving you the error?
    I don't yet do .net but from what I have heard it does not support DAO, so it could be that your "DAO.QueryDef" is causing the trouble.
    LVL 15

    Expert Comment

        Since you graded this question with a "C" I assume that you did not get a satisfactory Answer. For future questions, please feel free to give continuing feedback to you initial question and the experts' suggestions, that way we can work with you to get a solution that will hopefully end up working properly for your needs. In the link below we are working with another person on a similar question, and you might find the conclusion (when we reach it) even more helpful then what we have been able to post here.

    Looking to help...


    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Join & Write a Comment

    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    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…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    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

    22 Experts available now in Live!

    Get 1:1 Help Now