Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2012
    Posts
    7

    Question Unanswered: Recordset Navigation Issue, Access 2010

    Hi,
    Having an issue with trying navigation on a dao recordset.
    Here is code used:
    Private Sub Form_Current()
    Dim rst As DAO.Recordset
    Dim lngCount As Long
    Set rst = Me.RecordsetClone
    With rst
    .MoveLast
    .MoveFirst
    lngCount = rst.RecordCount
    End With
    Me.txtRecordNo = "Record " & Me.CurrentRecord & " of " & lngCount

    End Sub

    OK, I get complile error when opeing and when go to debug, It highlights
    Set rst = Me.RecordsetClone
    Says you have entered an expression that has invalid reference?
    I have DAO 3.6 checked in references

    I also have a txtbox called out txtRecordNo on form, I have 4 navigation buttons, MoveFirst, MoveNext, Move Prev, MoveLast. I cannot find any code samples that tell me what to do with these as far as on click property? Can someone please help out here
    Thank you so much
    Dave

  2. #2
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    119
    What exactly are you trying to do?
    The code looks ok but you could try this instead:

    Dim lngCount As Long
    With Me.RecordsetClone
    .MoveLast
    .MoveFirst
    lngCount = .RecordCount
    End With
    Me.txtRecordNo = "Record " & Me.CurrentRecord & " of " & lngCount
    Regards
    JD

    Software-Matters

  3. #3
    Join Date
    Jan 2012
    Posts
    7

    Solved

    Hi,
    The issue has been all along that I wanted to use unbound forms and I set to bound and it worked perfect except it is no longer unbound form. I cant find anything on doing this unbound so will continue with bound until I get more knowledgeable.
    Thanks

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Unbound forms have a Recordset that is set to Nothing and have no RecordSetClone property at all. This will raise an error when run in an unbound Form:
    Code:
    If Me.RecordSetClone is Nothing Then    ' "Run-time Error 7951:"
                                            ' You entered an expression that has an ivalid reference
                                            ' to the RecordSetClone property.
    Moreover, I don't understand why you would want to now the number of records of a form that has none.
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •