Selasa, 26 Juli 2011

[MS_AccessPros] Re: unrecognized database format...is this a reference problem ?

 

Hi Terence,

2 Things that may or may not apply to your situation that can give you a bad day if you are not aware of them:

1) Access 2007 does not set a reference to the ActiveX Data Objects Library for you. You have to set it yourself.

2) Windows 7 Service Pack 1 "broke" ADODB code. So if you have the SP1 installed so the only way you can get your code to work without uninstalling SP1 is to use Late Binding.

Early Binding:
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset

Late Binding:
Dim cnn As Object
Dim rst As Object

Set cnn = CreateObject("ADODB.Connection")
Set rst = CreateObject("ADODB.Recordset")

I like Bill's solution the best.

Kind Regards,
Pat Wood
http://accesstips.wordpress.com

--- In MS_Access_Professionals@yahoogroups.com, "Terence" <buffalome90210@...> wrote:
>
> This code worked with MDB, but I am now altering it for accdb. Code is as follows"
>
> Dim cnn As New ADODB.Connection
> Dim rst As New ADODB.Recordset
>
> cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
> "Data Source=C:\E_FORM\" & _
> "Database1.accdb;"
>
> rst.Open "Legacy3_filled", cnn, _
> adOpenKeyset, adLockOptimistic
>
> Does anything appear wrong? or am I using the wrong reference components ?
> Terence
>

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar