Re: Object variable or With block variable not set



Larry,

Thanks again and bottom of the class for Alastair. Fancy setting the return
to nothing before returning the values. I must of done a basic Recordcount
within the function and convinced myself that the problem was not in the
function.

Thanks again.

Alastair MacFarlane

"Larry Lard" wrote:

>
> Alastair MacFarlane wrote:
> > Dear All,
> >
> > Can someone please explain why I get the error at the line rsTemp.MoveFirst
> > in the FillListBox() sub I get the error:
> >
> > ?err.Number
> > 91
> > ?err.Description
> > Object variable or With block variable not set
> >
> > Which I understand what it means but not why? I have declared the Recordset
> > properly (I think). I have a sub that calls a function that returns the data.
>
> Sure? :)
>
> > I have checked this and it works fine.
>
> > Public Function GetDataMail() As ADODB.Recordset
> > Dim db As ADODB.Connection
> > Dim adoPrimaryRS As ADODB.Recordset
> > Set db = New Connection
> > db.CursorLocation = adUseClient
> > db.Open "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=\\sql01\Mail.mdb;"
> > Set adoPrimaryRS = New Recordset
> > adoPrimaryRS.Open "select EMail,MailID,Name from EMail", db, adOpenStatic,
> > adLockOptimistic
> > Set adoPrimaryRS = Nothing '**
> > Set db = Nothing
> > Set GetDataMail = adoPrimaryRS '**
> > End Function
>
> >From this it looks very much as if GetDataMail will always return
> Nothing, since adoPrimaryRS will always be Nothing when assigned to
> GetDataMail.
>
> Swap round the two lines I have marked ** and see how that goes.
>
> --
> Larry Lard
> Replies to group please
>
>
.



Relevant Pages

  • Optimizing code
    ... Set adoInstallerRS = New Recordset ... Set .RowSource = adoInstallerRS ... Set .DataSource = adoPrimaryRS ...
    (microsoft.public.vb.general.discussion)
  • Re: Type mismatch error
    ... Set adoStatusRS = New Recordset ... Set .RowSource = adoStatusRS ... Set .DataSource = adoPrimaryRS ...
    (microsoft.public.vb.general.discussion)
  • Type mismatch error
    ... Set adoStatusRS = New Recordset ... Set .RowSource = adoStatusRS ... Set .DataSource = adoPrimaryRS ...
    (microsoft.public.vb.general.discussion)
  • Re: Searching a recordset
    ... If you want to find the next AccountID for a given License, ... Find or Filter methods of the recordset for the License. ... > Set adoPrimaryRS = New Recordset ...
    (microsoft.public.vb.database.ado)