Re: DAO OpenRecordset returns... nothing?

Tech-Archive recommends: Speed Up your PC by fixing your registry



On 7 Jul 2006 11:47:22 -0700, "Keithius" <keithius@xxxxxxxxx> wrote:

¤ I've searched for days trying to figure this one out - I hope someone
¤ here can help me.
¤
¤ The problem, in a nutshell, is this: I've got a Recordset object and a
¤ Database object. The database is an Access MDB database that is open.
¤ The Recordset object is a brand new, just dim-ed variable. Here is the
¤ simplified code:
¤
¤ set myRecordset = myDatabase.OpenRecordset(someQuery)
¤
¤ do while myRecord.EOF = False
¤ ' do something
¤ loop
¤
¤ (Assume that "someQuery" is a valid query, but that it happens to
¤ return 0 (zero) rows from this particular database.)
¤
¤ The problem occurs at the start of the "do" loop; or more specifically,
¤ when ANY member of the "myRecord" object is accessed. The error is
¤ "object variable or with block variable not set." The problem only
¤ seems to occur if "someQuery" returns 0 (zero) rows.
¤
¤ If I'm not mistaken, when OpenRecordset returns 0 (zero) rows, it
¤ should still return a Recordset object; but it would set the .EOF
¤ property to "True." At least, that's how all the MSDN documentation
¤ seems to read.
¤
¤ I'm at a loss here - I can't figure this one out. Anyone have any
¤ ideas?

You have "myRecordset" and your loop is executed on "myRecord". Is this a typo? If not this would
most certainly explain the error message.


Paul
~~~~
Microsoft MVP (Visual Basic)
.



Relevant Pages

  • Re: vb6, win2000, access 2000
    ... ¤ these are the lines of code i am using: ... ¤ Public ActualDatabaseLocation As String ... ¤ Public dbDetail01 As Database ... -this is the error message that pops up ...
    (microsoft.public.vb.database)
  • Re: Cannot open a database from a previous version of your application
    ... ¤ I have a VB.net program installed in a xp home with sp2,after ... The database is a 97 Access file. ... ACC2000: Error Message: Cannot Open Database Created with a Previous Version ... Microsoft MVP ...
    (microsoft.public.dotnet.languages.vb)
  • Re: VB6 ADO problem
    ... ¤ Hi folks, ... recordset object get set to 'nothing' even though it was successfully ... ¤ Dim dbo as ADODB.Connection ...
    (microsoft.public.vb.database.ado)
  • Re: Can I add columns to an existing recordset?
    ... ¤ The title explains it. ... to the resulting ado recordset, iterate through the recordset and put ... the Fields collection of a Recordset object has an Append method that will enable you to add ...
    (microsoft.public.vb.general.discussion)
  • Re: Load Picture from MS Access to VB6
    ... in code to compact the database via a menu option. ... there is a chance the filename of the photo itself can ... > ¤ Well, I figured it out I think. ... loaded images into the database directly through Access (so that I could ...
    (microsoft.public.vb.general.discussion)