If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Recordset Navigation Issue, Access 2010

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-11-12, 15:41
d9pierce d9pierce is offline
Registered User
 
Join Date: Jan 2012
Posts: 7
Question 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
Reply With Quote
  #2 (permalink)  
Old 01-12-12, 11:10
SoftwareMatters SoftwareMatters is offline
Registered User
 
Join Date: Mar 2009
Location: Dorset
Posts: 78
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

Bespoke Access Database Design and Development Services
Software Matters - Simple Solutions That Work!
Reply With Quote
  #3 (permalink)  
Old 01-12-12, 14:35
d9pierce d9pierce is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 01-12-12, 15:04
Sinndho Sinndho is offline
Registered User
 
Join Date: Mar 2009
Posts: 3,446
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!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On