AlexanderBB
Well-known Member
- Joined
- Jul 1, 2009
- Messages
- 2,099
- Office Version
- 2019
- 2010
- Platform
- Windows
Hi the following should work, but I'm missing something. It results in
Run-time error '3061':
Application-defined or object-defined error
It should return a recordset from Access back to Excel.
Added References:
IMicrosoft DAO 3.6 Object Library
Microsoft ActiveX Data Objects 2.8 Library
Run-time error '3061':
Application-defined or object-defined error
It should return a recordset from Access back to Excel.
Added References:
IMicrosoft DAO 3.6 Object Library
Microsoft ActiveX Data Objects 2.8 Library
VBA Code:
Option Explicit
Dim DataBank As DAO.Recordset
Sub Doit()
Set DataBank = GetMyData("James")
stop
End Sub
Function GetMyData(S) As DAO.Recordset
Dim sql As String
sql = "Select Balance From tblMain Where FName= " & Chr$(34) & S & Chr$(34) & ";"
With MyList.CreateQueryDef("", sql)
Set GetMyData = .OpenRecordset
.Close
End With
End Function
Function MyList() As DAO.Database
Set MyList = DAO.OpenDatabase("C:\DB\Build1.mdb", False, False)
End Function