Results 1 to 5 of 5

Dao

  1. #1
    evander is offline Competent Performer
    Windows 7 Access 2003
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    206

    Post Dao

    I've created a custom function in VBA that looks up a value in some table using DAO code.



    My problem is, I need to test whether the DAO recordset contains something, and that is by doing .MoveLast and .MoveFirst. I can't test for emptiness of the recordset unless I execute these methods. But when I do these methods on a recordset that is empty in the first places, I run into an error.

    Is there a way for me to avoid this, so that when the recordset is empty, I can tell the function to return a zero value instead?

    Thanks in advance.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    To see if the recordset contains any records at all, I test for .EOF. As you've found, .MoveLast will error if there are no records.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    evander is offline Competent Performer
    Windows 7 Access 2003
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    206
    Thanks Paul. I'll implement your solution now.

  4. #4
    evander is offline Competent Performer
    Windows 7 Access 2003
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    206
    Paul, it works! I'm so excited.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums