Trying to create a querydef in an access 2000 database with vb.net

    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

            DAO.QueryDefs.Append(qdfTemp)

            CreateNewQuery = qdfTemp

        End With

I am getting the following error:

reference to a non-shared member requires an object reference


dressmanAsked:
Who is Participating?
 
will_scarlet7Commented:
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.
0
 
SanclerCommented:
What is

CreateNewQuery?

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.

Roger
0
 
will_scarlet7Commented:
dressman,
    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...

Sam

http://www.experts-exchange.com/Databases/MS_Access/Q_21454698.html
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.