ich habe folgende Funktion geschrieben, die den Connect zur Access-DB herstellen soll.
Private Function connectToDatabase() As ADODB.Connection
Dim DBFullName As String
Dim Cnct As String, Src As String
Dim Connection As ADODB.Connection
Dim Recordset As ADODB.Recordset
Dim Col As Integer
Dim team As String
'Cells.Clear
' Database information
DBFullName = ThisWorkbook.Path & "\PMO.mdb"
' Open the connection
Set Connection = New ADODB.Connection
Cnct = "Provider=Microsoft.Jet.OLEDB.4.0; "
Cnct = Cnct & "Data Source=" & DBFullName & ";"
Connection.Open ConnectionString:=Cnct
connectToDatabase = Connection
End Function
Die Funktion soll das Connection Objekt zurückgeben. Aber wenn ich die Funktion ausführe, dann kommt in der folgenden Zeile
connectToDatabase = Connection
folgender Fehler:
Object variable or With block variable not set
Weiss jemand von euch, was hier falsch läuft? :/
lg pat