Can't Late Bind Access App

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to late-bind the Access 2002 app Object from VB.net. The GetObject and CreateObject statements return an error: "Cannot create ActiveX component". Anyone know what's going on? I've tried many ways to identify the application correctly.....MSACCESS, MSACC, Access, Microsoft Access, Access.Application.9, Access.Application.10....... and nothing works. This is to correct a conflict when compiling VBA in access across 2 versions of Access - 2000 and 2002, which have different Object Libraries.
 
You'll have to show us the code you're trying to use if you want us to help.
Few of us are prescient!

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Linda said:
I am trying to late-bind the Access 2002 app Object from VB.net. The
GetObject and CreateObject statements return an error: "Cannot create
ActiveX component". Anyone know what's going on? I've tried many ways to
identify the application correctly.....MSACCESS, MSACC, Access, Microsoft
Access, Access.Application.9, Access.Application.10....... and nothing
works. This is to correct a conflict when compiling VBA in access across 2
versions of Access - 2000 and 2002, which have different Object Libraries.
 
It's

Set AccessApp = GetObject("Access.Application")

The Set keyword is mandatory.

If you're doing stuff with Automation, you might find this KB article
useful:
http://support.microsoft.com/default.aspx?scid=kb;[LN];210111


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Linda said:
Sorry - new to this stuff.....does it show?

This is the last version of the code that I've tried...

Dim AccessApp As Object

On Error Resume Next
' If access is not already open, create an instance of access
AccessApp = GetObject("MSAccess.Application")
If AccessApp Is Nothing Then
AccessApp = CreateObject("MSAccess.Application")
If AccessApp Is Nothing Then
MsgBox("Could not start Access. CAP application will quit")
End
End If
End If

It now fails gracefully, but still fails whether I have Access open or
not. The VB.net compiler removes the SET syntax that is required in vb 6.0.
I've tried "Access.Application", "Access.Application.10" (as suggested in
some documentation), "MSACC" (name of .OLB) and just about everything in
between.
 
Thanks Douglas. For some reason my editor keeps removing the SET command after I type it in and hit return...... I'll read up on it some more. Thanks again.
 
Back
Top