I am using Access and XL 2000 and through VBA I want xl to call a procedure in an access DB I have set a reference to access in xl but it still crashes each time it trys to set the object to a new access.application
here is my code what am I doing wrong and is there a better way to do it. I also I want to take even on step further and pass in variables to the procedure.
Sub RunFunction()
Dim sDBPath As String
Dim appAccess As Access.Application
sDBPath = Workbooks(1).Path & "\Mydb.mdb"
'It bombs here and tells me it can't create Active X object
Set appAccess = New Access.Application
appAccess.OpenCurrentDatabase sDBPath
appAccess.DoCmd.OpenModule "ModuleName", "Function"
'run the function
appAccess.DoCmd.RunCommand acCmdRun
Set appAccess = Nothing
End Sub
here is my code what am I doing wrong and is there a better way to do it. I also I want to take even on step further and pass in variables to the procedure.
Sub RunFunction()
Dim sDBPath As String
Dim appAccess As Access.Application
sDBPath = Workbooks(1).Path & "\Mydb.mdb"
'It bombs here and tells me it can't create Active X object
Set appAccess = New Access.Application
appAccess.OpenCurrentDatabase sDBPath
appAccess.DoCmd.OpenModule "ModuleName", "Function"
'run the function
appAccess.DoCmd.RunCommand acCmdRun
Set appAccess = Nothing
End Sub