I work on an Access DB and I have to use a Datasource connection to a SQL Server.
To do that I use the ADODB object with :
-ADODB.Connection
-ADODB.Recordset
Code Up-to-date, following an observation of Ian Kenney
Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
Dim rs As ADODB.Recordset
cnn.ConnectionString = "driver={SQL Server};provider=SQLOLEDB;server=10.****;uid=****readonly;pwd=****readonly;database=****"
cnn.Open
Set rs = cnn.Execute("SELECT [MATRI], [NOMPRE] FROM SCHEME_DB.TABLE WHERE NOMPRE LIKE '*" & Me.Textbox_recherche.Text & "*'")
Me.Liste_choix.RowSourceType = "Table/List"
Me.Liste_choix.Recordset = rs
rs.Close
cnn.Close
(This code (a part of the code) is a way to do an Autocompletion in Access with a TextBox and a ListBox)
And I have an error 91 when I run this code : "Error 91: Object variable or With block variable not set" .
I don't understand how to resolve this issue.
Thanks in advance.