taporctv
03-21-2008, 06:58 AM
I'm having a little trouble with an Access object I created within excel. Here's the code:
Dim myAccess As access.Application
Dim myDB As Database
Set myAccess = CreateObject("Access.Application")
' Relative path
Dim CurDir As String
CurDir = ThisWorkbook.Path & "\IA Testing.mdb"
' myAccess.Application.Visible = False 'if you don't run this the database will run in the background hidden
myAccess.OpenCurrentDatabase (CurDir)
' open access query normally
myAccess.Visible = False
myAccess.DoCmd.OpenQuery (query)
Application.DisplayAlerts = False
If NoMyRs = False Then
' create recordset
Set myDB = myAccess.CurrentDb()
Set myRS = myDB.OpenRecordset(query)
End If
myAccess.Quit
Set myAccess = Nothing
Everything if fine until I run myAccess.quit. After this line of code is executed, an Access window pops up. How do I prevent this? May I be overlooking something?
Dim myAccess As access.Application
Dim myDB As Database
Set myAccess = CreateObject("Access.Application")
' Relative path
Dim CurDir As String
CurDir = ThisWorkbook.Path & "\IA Testing.mdb"
' myAccess.Application.Visible = False 'if you don't run this the database will run in the background hidden
myAccess.OpenCurrentDatabase (CurDir)
' open access query normally
myAccess.Visible = False
myAccess.DoCmd.OpenQuery (query)
Application.DisplayAlerts = False
If NoMyRs = False Then
' create recordset
Set myDB = myAccess.CurrentDb()
Set myRS = myDB.OpenRecordset(query)
End If
myAccess.Quit
Set myAccess = Nothing
Everything if fine until I run myAccess.quit. After this line of code is executed, an Access window pops up. How do I prevent this? May I be overlooking something?