Help pls change ADODB.Recordset and adodb.connection with New.ADODB.Recordset and New.adodb.connection
in that code:
in that code:
Code:
Option Explicit Function DataSql(dt_sql) DataSql = "#" & Format(dt_sql, "mm\/dd\/yy hh\:mm\:ss") & "#" End Function Function GetAccessConnect(FilePath As String) Dim sCon As String, strMyDBPassword As String Set GetAccessConnect = CreateObject("adodb.connection") strMyDBPassword = "642531" With GetAccessConnect .CursorLocation = 3 sCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" sCon = sCon & FilePath & ";Jet OLEDB:Database Password=" & strMyDBPassword & ";" .Open sCon End With End Function Sub test55() Set Cn = GetAccessConnect(ThisWorkbook.Path & "\data.accdb") Set Rs = CreateObject("ADODB.Recordset") End Sub Function GetRs(Cn, sstr) Set GetRs = CreateObject("ADODB.Recordset") GetRs.Open sstr, Cn, 3, 3 End Function