Creating a Recordset object in a function.

Posted on 2004-11-02
Last Modified: 2010-04-23

I am tring to create a recordset object to be used on other pages.  Everythng in the code works until i get to:

rsEmailList.CursorLocation = ADODB.CursorLocationEnum.adUseClient

Then I get and error that says "Object reference not set to an instance of an object".  I am not sure how to set the object when I am creating this type of function.


    Public Function rsEmailList() As ADODB.Recordset
        Dim cmdEmailList As New ADODB.Command
        cmdEmailList.CommandText = "selLAStageTixAddress"
        cmdEmailList.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
        cmdEmailList.ActiveConnection = objConn
        rsEmailList.CursorLocation = ADODB.CursorLocationEnum.adUseClient
        rsEmailList.LockType = ADODB.LockTypeEnum.adLockReadOnly
        rsEmailList = cmdEmailList.Execute
    End Function


Thank you.
Question by:GabicusC
    1 Comment
    LVL 48

    Accepted Solution

    Public Function rsEmailList() As ADODB.Recordset
            dim rs as adodb.recordset

      set rs = new adodb.recordset

    blah blah

      rsEmailList = rs
        End Function

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    This video discusses moving either the default database or any database to a new volume.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now