Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Access not closing properly via vb.net: Still in memory

Avatar of Fordraiders
FordraidersFlag for United States of America asked on
Visual Basic.NET
1 Comment1 Solution275 ViewsLast Modified:
vb.net 2003
Office 2003
Access not closing properly via  vb.net.

' Calling from vb.net
Public Sub ExportBrand(ByVal strName As String, ByVal strCat As String)
        ' CAN USE IF NEEDED 01292007
        ' long execution go and make excel to visible . false:  STRAIGHT CALL TO ACCESS FOR DATA
        Dim oAccess As New Microsoft.Office.Interop.Access.Application
        'Start Access and open the database.

        oAccess = CreateObject("Access.Application")
        oAccess.Visible = False
        oAccess.OpenCurrentDatabase("C:\dm2007\SkuCat.mdb", False)
        'Run the procedure
        '  oAccess.DoCmd.RunMacro(mcrName)
        oAccess.Run("CallExportG", strName, strCat)     'Clean-up: Quit Access without saving changes to the database.
        '  oAccess.CloseCurrentDatabase()
        MsgBox("Done Exporting Grainger Brand")
        oAccess = Nothing
    End Sub

While in Access this is running and closing:
Public Sub CallExportG(strName As String, strCat As String)
 ExportCombo strName, strCat
End Sub

Public Sub ExportCombo(strMfrnam As String, strCat As String)

Dim strSql As String, qd As DAO.QueryDef
Set qd = CurrentDb.QueryDefs("BrandQuerySql")

strSql = "SELECT tblCoreSkuInformation.ITEM, tblCoreSkuInformation.WWGMFRNAME, "
strSql = strSql & "tblCoreSkuInformation.WWGMFRNUM, tblCoreSkuInformation.WWGDESC, "
strSql = strSql & "tblCoreSkuInformation.RICHTEXT , tblCoreSkuInformation.SPIN, "
strSql = strSql & "tblCoreSkuInformation.REDBOOKNUM, tblCoreSkuInformation.UOM, tblCoreSkuInformation.[UOM Qty], "
strSql = strSql & "tblCoreSkuInformation.[Customer Willcall Qty], tblCoreSkuInformation.[Customer Ship Qty], "
strSql = strSql & "tblCoreSkuInformation.ALT1, tblSkuCat.[Segment Name], tblSkuCat.[Category Name]"
strSql = strSql & "FROM tblCoreSkuInformation LEFT JOIN tblSkuCat ON tblCoreSkuInformation.ITEM = tblSkuCat.[Grainger SKU]"
strSql = strSql & "WHERE (((tblCoreSkuInformation.WWGMFRNAME)='" & strMfrnam & "') AND ((tblSkuCat.[Category Name])='" & strCat & "' ));"

qd.SQL = strSql

DoCmd.TransferSpreadsheet acExport, 8, "BrandQuerySql", "C:\DM2007\Export_Template.xls", True, ""
Set qd = Nothing
End Sub

One instance of Access is still left iin memory  after  running these routines  ??

Avatar of Hillwaaa
HillwaaaFlag of Australia image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answers