ADO compatibility

G

Guest

Am using Access 97.

I have a file I created. In my References, I have ADO Ext 2.8. I gave the
file to a colleague. Open opening the file, she received an error because
her Reference library does not have ADO Ext 2.8 She has 2.7.

When I give files to colleagues, I don't know what libraries they have
installed. So what is a solution to assure compatibity?

Thanks,

Janie
 
D

Douglas J. Steele

Rather than setting a reference, and then declaring variables as

Dim objCatalog As ADOX.Catalog

Set objCatalog = New ADOX.Catalog
objCatalog.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & DatabaseName & ";" & _
"Jet OLEDB:Engine Type=4;"

you use

Dim objCatalog As Object

Set objCatalog = CreateObject("ADOX.Catalog")
objCatalog.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & DatabaseName & ";" & _
"Jet OLEDB:Engine Type=4;"

It means that you have to be careful not to used intrinsic variables defined
in the library. For instance, rather than

Set objKey = New ADOX.Key
With objKey
.Name = "AlbumFile"
.Type = adKeyForeign
.RelatedTable = "Album"
.Columns.Append "AlbumId"
.Columns("AlbumId").RelatedColumn = "AlbumId"
End With

you need to use

Set objKey = CreateObject("ADOX.Key")
With objKey
.Name = "AlbumFile"
.Type = 2
.RelatedTable = "Album"
.Columns.Append "AlbumId"
.Columns("AlbumId").RelatedColumn = "AlbumId"
End With


You might find http://www.dicks-clicks.com/excel/olBinding.htm to be useful.
While written for Excel, the exact same concepts hold true in Access.
 
O

onedaywhen

Rather than setting a reference, and then declaring variables as

Dim objCatalog AsADOX.Catalog

Set objCatalog = NewADOX.Catalog
objCatalog.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & DatabaseName & ";" & _
"JetOLEDB:Engine Type=4;"

you use

Dim objCatalog As Object

Set objCatalog = CreateObject("ADOX.Catalog")
objCatalog.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & DatabaseName & ";" & _
"JetOLEDB:Engine Type=4;"

It means that you have to be careful not to used intrinsic variables defined
in the library. For instance, rather than

Set objKey = NewADOX.Key
With objKey
.Name = "AlbumFile"
.Type = adKeyForeign
.RelatedTable = "Album"
.Columns.Append "AlbumId"
.Columns("AlbumId").RelatedColumn = "AlbumId"
End With

you need to use

Set objKey = CreateObject("ADOX.Key")
With objKey
.Name = "AlbumFile"
.Type = 2
.RelatedTable = "Album"
.Columns.Append "AlbumId"
.Columns("AlbumId").RelatedColumn = "AlbumId"
End With

You might findhttp://www.dicks-clicks.com/excel/olBinding.htmto be useful.
While written for Excel, the exact same concepts hold true in Access.

Further point: for the example of ADOX.Catalog, in my registry I have
classes for "ADOX.Catalog.2.7" and "ADOX.Catalog.2.8" as well as the
"ADOX.Catalog" which will resolve to the later i.e. the 2.8 version.

It is usually the case that you requires the lowest common denominator
"ADOX.Catalog" approach but if you require version-specific
functionality you can mix-and-match using late binding e.g. you can
test explicitly for the presence "ADOX.Catalog.2.8" (using CreateObject
and testing for errors) to leverage newer functionality only where
available.

Jamie.

--
 
D

Douglas J. Steele

onedaywhen said:
Further point: for the example of ADOX.Catalog, in my registry I have
classes for "ADOX.Catalog.2.7" and "ADOX.Catalog.2.8" as well as the
"ADOX.Catalog" which will resolve to the later i.e. the 2.8 version.

It is usually the case that you requires the lowest common denominator
"ADOX.Catalog" approach but if you require version-specific
functionality you can mix-and-match using late binding e.g. you can
test explicitly for the presence "ADOX.Catalog.2.8" (using CreateObject
and testing for errors) to leverage newer functionality only where
available.

Good point, Jamie
 

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