GetRecodset (sSQL, Optional maxRecords) as ADODB.Recordset '
Function GetRecordset(sSQL As String, Optional cn, Optional QueryOrSQL, Optional p1, Optional p2, Optional p3, Optional p4) As ADODB.Recordset
Dim rs As New ADODB.Recordset
'Dim rs1 As New ADODB.Command
Dim cmd As New ADODB.Command
If IsMissing(cn) Then
Set cn = gADO
End If
If IsMissing(QueryOrSQL) Then
QueryOrSQL = "S"
End If
If cn Is Nothing Then
'conADO.Open "Data Source=" & datasource
Set cn = GetConnection()
'Else
' Set conADO = ADO
End If
'myConnection.Open
' Determine if we conected.
If cn.State = adStateOpen Then
'MsgBox "Welcome to the Biblio Database!"
Else
'MsgBox "The connection could not be made."
Set cn = GetConnection()
End If
If QueryOrSQL = "S" Then
Set rs = cn.Execute(sSQL)
Set GetRecordset = rs
Exit Function
Else
With cmd
Set .ActiveConnection = cn
.CommandText = sSQL
.CommandType = adCmdStoredProc