Having a problem with this connecting to Access
I use it in VB6 and just ported it into Excel but getCode:Function Dlookup(Field, Domain, Criteria) As String Dim r As DAO.Recordset Dim sql As String sql = "Select " & Field & " from " & Domain & " Where " & Criteria With MyCurrentDB.CreateQueryDef("", sql) Set r = .OpenRecordset If r.RecordCount > 0 Then Dlookup = r(0) .Close End If Set r = Nothing End With End Function Function MyCurrentDB() As DAO.Database Set MyCurrentDB = DAO.OpenDatabase("C:\DB\Test.mdb") End Function
Run-time error '3075':
Application-defined or object-defined error
I suspect References and have Microsoft DAO 3.6 Object Library but do I need something else?
Or have mucked something in the code ?
Thanks