Maenne said:
Hi,
The version is MsAccess 2000 with ending *.mdb
The error message in german:
Microsoft Visual Basic
Laufzeitfehler '428'
Objekt unterstützt diese Eigenschaft oder Methode nicht
and now the complete code:
'--------Module------------
Option Compare Database
Global cn 'Connection
Global Adressen 'Tabelle Adressen
Sub OeffneDb(DbName As String)
Set cn = CreateObject("ADODB.Connection")
Set Adressen = CreateObject("ADODB.Recordset")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" &
DbName
End Sub
Sub SchliesseDb()
Adressen.Close
cn.Close
End Sub
'-----Form-------------------
Option Compare Database
Private Sub Form_Open(Cancel As Integer)
Call OeffneDb("D:\MSAccess_ADO\ADOData.mdb")
Set Adressen = CreateObject("ADODB.Recordset")
Adressen.Open "SELECT [AdrId],[Nachname],[Vorname] FROM
[Adressen];", cn, adOpenKeyset, adLockOptimistic, adCmdText Set
Me!Suche.RowSource = Adressen Call SchliesseDb
End Sub
RoyVidar said:
Maenne wrote:
Sorry,
that didn't work too, but I told you something wrong first.
I used the following statement in my code:
Adressen.Open "SELECT [AdrId],[Nachname],[Vorname] FROM
[Adressen];", cn, adOpenKeyset, adLockOptimistic, adCmdText
I thing that's what you meant.
Maenne wrote:
Hi,
thanks for your answer. I tried it out, but that produces
an error like (I try to translate)
runtime error '438'
Object does not support this property oder method
Newsbeitrag Try:
Set Me!Suche.RowSource = Adressen
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
Hi everybody,
i hope you can help me.
Formerly i used a stored query to fill the rowsource of a
combinationfield.
Now i want to use the ADO-method to do the same, but
somthing is wrong with my access-program:
Sub OeffneDb(DbName As String)
Set cn = CreateObject("ADODB.Connection")
Set Adressen = CreateObject("ADODB.Recordset")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" &
DbName 'D:\ADOData.mdb"
End Sub
Sub SchliesseDb()
Adressen.Close
cn.Close
End Sub
Private Sub Form_Open(Cancel As Integer)
Call OeffneDb("D:\MSAccess_ADO\ADOData.mdb")
Adressen.Open "SELECT [AdrId],[Nachname],[Vorname] FROM
[Adressen]" Me!Suche.RowSource = cn.Adressen
'<-----that doesn't work
Call SchliesseDb
End Sub
The combinationfield is named by Me!Suche
My difficult is, that the query is not in mdb-file, where the
form is placed. It is in an external mdb-file.
Can s.o. help me please? (sorry for my english, i'm german)
Try
Set Me!Suche.Recordset = Adressen
But - if I recall correct, you might have to set some of the
recordset properties, but I don't recall which - I think the
following should work though (but have added some extras):
Set Adressen = CreateObject("ADODB.Recordset")
With Adressen
.CursorType = 3 ' adOpenStatic
'.CursorLocation = 2 ' adUseServer
'.LockType = 3 ' adLockOptimistic
End With
--
Roy-Vidar
Could we please have the whole code pertaining to this, and also
the last errormessage - when you assigned to the combos *recordset*
property (not rowsource).
Also, which version of Access and what is the row-source type of
your combo - I think it should be "table/query" for mdb file.
Is it adp or mdb?
Oh, sorry, now I see you're using Access 2000. The recordset property
that makes it possible to assign recordsets, became available in the
2002 version.
In the 2000 version, there are several limitations.
You can use Value list as RowSourceType and assign the result of the
recordset through the .GetString method - BUT - the limitation is
that the max length of the Value List is 2048 characters.
Me!Suche.RowSourceType = "Value List"
Me!Suche.RowSource = Adressen.GetString(adClipString,,";",";")
But again, the length of the Row Source cannot exceed 2048.
Another option, would be to use something like the following as
rowsource:
Me!Suche.RowSourceType = "Table/Query"
Me!Suche.RowSource = "SELECT [AdrId],[Nachname],[Vorname] FROM [" & _
DBNAME & "].[Adressen]"
I e, fetching it from the other database like the above, where the
resulting SQL could look like this
SELECT [AdrId],[Nachname],[Vorname] FROM [D:\ADOData.mdb].[Adressen]