Can't Late Bind Access App

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.
 
D

Douglas J. Steele

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.
 
D

Douglas J. Steele

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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top