Disconnected Recordset function in remote MDE file



What am i doing wrong? I'm a newbie
I have the following code:
'''''''START CODE'''''''''''''
Option Compare Database
Option Explicit

Public rstTariffs As ADODB.Recordset

Public Sub createDiscRecordset(Rec2Fill As Recordset, strDBpath As
String, strNameQuery As String)
'This function fills recordsets and disconnects them
On Error Resume Next
Dim strSQL, strConn As String
Dim rs As New ADODB.Recordset

rs.CursorLocation = adUseClient
strConn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" &
strDBpath & ";Uid=;Pwd=;"

rs.Open strNameQuery, strConn, adOpenStatic, adLockBatchOptimistic

'Disconnect the recordset
Set rs.ActiveConnection = Nothing

'Return the recordset
Set thaRecordset2Fill = rs
End Sub

Public Sub test()
Dim strPath As String
strPath = "c:\test.mdb"

Call createDiscRecordset(rstTariffs, strPath, "select * from
tariffs")
Debug.Print rstTariffs.RecordCount
End Sub
'''''''END CODE'''''''''''''

It works fine if I leave all the code in the local database.
But i want to put the code from sub createDiscRecordset in an remote
mde file and reference to it.
But upon running it after putting the code in the mde file. It does not
seem to work. When running the test sub, i get the following message
'91 : Object variable or With block variable not set'.
Please advice.

Thank you

.



Relevant Pages

  • Re: Emailing a Report
    ... You must remember to enclose literal values in quotes and concatenate them; the final string must have commas too, ... Sub LoopAgmtsSendEmail(_ ... pSQL As String) ... 'pSQL -- defines the recordset to open ...
    (microsoft.public.access.modulesdaovba)
  • Re: Recordset object loses validity in call between function & subrout
    ... Sub DAORecordsetQuery(ByRef rs As DAO.Recordset, ... argConnectionString As String, _ ... In ADO, Recordset is a top level object, so you don't need to ... Dim rs As ADODB.Recordset ...
    (microsoft.public.excel.programming)
  • Re: Emailing a Report
    ... 'pSQL -- defines the recordset to open ... the final string must have commas too, ... Private Sub cmdSendEmail_Click ... pSQL As String) ...
    (microsoft.public.access.modulesdaovba)
  • Re: Emailing a Report
    ... make sure you have a reference to a Microsoft DAO Library ... The Sub LoopAgmtsSendEmail is highlighted by the Debugger. ... 'pSQL -- defines the recordset to open ... You must remember to enclose literal values in quotes and concatenate them; the final string must have commas too, ...
    (microsoft.public.access.modulesdaovba)
  • Re: Thread issue
    ... I actually do not want to create a log system. ... Private mLogFile As String ... Public Sub New ... Public Sub LogMessage ...
    (microsoft.public.dotnet.languages.vb)