Results 1 to 2 of 2
  1. #1
    Drawn is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    1

    Question Over My Head: Custom Recordset Property

    Doing some volunteer work for a the Kidney Foundation.

    Working on a small Access database.

    I'm an old Foxpro programmer.

    MS Access is not my thing, but volunteering is a good thing.

    Would someone show me the means to have a second recordset associated with the existing form, please.

    Below is my first effort:
    Code:
     
    Option Compare Database
    Private cn As ADODB.Connection
    Private rstCallers As Recordset
    ________________________________________________
     
    Public Sub initRecordSet()
    Dim rs As ADODB.Recordset
    Set cn = CurrentProject.Connection
     
    Set rs = New ADODB.Recordset
     
    With rs
     
    Set .ActiveConnection = cn
     
    .Source = "SELECT * FROM ClientCaller"
     
    .LockType = adLockOptimistic
     
    .CursorType = adOpenKeyset
     
    .Open
    End With
     
    Set Me.Recordset = rs
     
    ' Here's a second reordset to be referenced as a property of the current form.
    ' This routine is being called in the form's Load event.
    Set rstCallers = CurrentDb.OpenRecordset("select clientId from ClientCaller group by clientId", dbOpenSnapshot)
     
    End Sub
    I noticed, once this routine is run, in the Watches screen the form's property, Recordset, is of type, Object/Recordset.

    The 'custom' property, rstCallers, is of type, Recordset/Recordset2

    Is this because of the use of OpenRecordset()?

    Should it not be of the type, Object/Recordset?


    I'm getting an error when I later try to reference the property.

    Must be a syntax error, I'm thinking.

    Again, MS Access bit of a learning curve for me.

    The error: Run-time error '2465': Application-defined or object-defined error.
    Code:
     
    Private Sub cmdStaff_check()
    Dim frm As Form
     
    Set frm = Forms!frmEntry
     
    If frm.rstCallers.EOF Then ' <-- Run-time error '2465':
    :
    :
    End Sub
    What's the cause and the cure of this error?



    Much thanks.


    Drawn

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    first, you are trying to use a recordset object as a property, which won't work. If you're interested in the recordset that's bound to that form, you need to do this:
    Code:
    set rstCallers = frm.recordsetclone
    and then:
    Code:
    if rstCallers.eof then
    also, I don't believe that 'dbOpenSnapshot' allows manipulation, or even movement. I'm not sure though. check vba help files. I know it's completely different than the other types.

    FYI, the watch window issue more than likely is related to the DLL libraries that your objects are coming from. You're using one recordset from the DAO library and one from the ADO library, and of course they are not the same things.

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

Similar Threads

  1. the property is read only and cannot be set
    By darksniperx in forum Access
    Replies: 16
    Last Post: 11-02-2012, 02:48 PM
  2. My head is starting to spin
    By eww in forum Queries
    Replies: 1
    Last Post: 08-30-2010, 02:43 PM
  3. Help banging my head against a wall working on this
    By Brian Foshee in forum Programming
    Replies: 1
    Last Post: 06-04-2010, 08:30 AM
  4. In over my head with a database class
    By fixittech in forum Database Design
    Replies: 3
    Last Post: 01-22-2010, 07:45 AM
  5. Replies: 1
    Last Post: 11-13-2009, 03:03 AM

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