Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    d9pierce1 is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776

    Question Navigation in DAO Recordset Issue

    Hi all,
    I have worked some with Access direct edit but am new on the DAO Recordsets and unbound forms so trying to learn them. I started a new db today and was able to get populated but starting to put navigation on the form and ran into some errors to debug. I have searched and searched and just cant find a solution. Here is the code:

    Option Compare Database

    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


    Private Sub Form_Load()


    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    Set db = CurrentDb()
    Set rst = db.OpenRecordset("tblCompany")
    If rst.RecordCount = 0 Then Exit Sub
    txtCompanyID = rst.Fields![CompanyID]
    txtCompanyUID = rst.Fields![CompanyUID].Value
    txtCompanyName = rst.Fields![CompanyName].Value
    txtCreation = rst.Fields![Created].Value
    txtModified = rst.Fields![Modified].Value
    rst.Close
    Set rst = Nothing
    Set db = Nothing
    End Sub

    Now, I get a compile error on form open and highlights the " Set rst = Me.RecordsetClone" (above) and says something about a reference invalid. I have 4 buttons on form I made for MoveFirst, MoveLast, MoveNext, and MovePrev and I cant find any reference to what should go as far as OnClick for the buttons.
    Could I please get some help with this as very strange there are no examples that I can get to work on the www?
    Thanks
    Dave
    Last edited by d9pierce1; 01-11-2012 at 06:12 PM. Reason: space between code!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Have you checked to see when the CurrentEvent occurs?

  3. #3
    d9pierce1 is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Hi and thanks for responding. The error happens on form open but I am not actually sure what you are speaking of? I used this example off of a website and I must be missing something? I just dont know as it cant be this complicated.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You are not showing anything in the OpenEvent. I'm confused.

  5. #5
    d9pierce1 is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Hi RG,
    I just started this so I can learn how to use DAO and Transactions. This is a new db and so far I made a table, form, and got it to populate by OnLoad function which works well. I am very confused with recordsets and workspaces so trying to understand them so I can use them. I couldnt find any thing on navigation and record counts other then this and it didnt really give any good info onit. I couldnt actually find a sample of it that I could actually understand but am trying. Just building one db to get familiar with how unbound, dao, and recordsets work. Thanks

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You get a Current Event *every* time you enter a different record. You are moving the record pointer in that same event which is basically a forever loop.

  7. #7
    d9pierce1 is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Evidently not! Not sure how to do that? The only code is what I have ablove for the whole begining.

  8. #8
    d9pierce1 is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Hi RG,
    Do you possible know of a site that has a real example that works of this? Small sample db or something to this?
    Thanks

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Hmm...in looking at the code again, your playing with the RecordsetClone in the Current Event and that should not cause you a problem. Try *importing* your db into a fresh new db and see if the problem follows. What you have should work. http://www.btabdevelopment.com/ts/impnew

  10. #10
    d9pierce1 is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Hi RG,
    Just tried that and same thing. Really is getting baffeling! Could I need something else like a look somewhere in this. It is driving me nuts and I have read every articale possible and no luck?
    Thanks

  11. #11
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Zip up the db and post it and I'll take a look at it.

  12. #12
    d9pierce1 is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    How do I attache it?

  13. #13
    d9pierce1 is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    I dont have a manage attachment button at the bottom?

  14. #14
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Go to advanced and scroll down.

  15. #15
    d9pierce1 is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    OK, Found oout how! Thanks and here it is
    Dave

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Navigation Bar
    By hitesh_asrani_j in forum Forms
    Replies: 5
    Last Post: 10-24-2011, 10:19 AM
  2. Navigation form
    By Wayne311 in forum Programming
    Replies: 10
    Last Post: 02-10-2011, 01:06 PM
  3. Help with navigation
    By phelpsville in forum Access
    Replies: 0
    Last Post: 04-16-2010, 07:33 PM
  4. Navigation Pane Issue
    By mimi in forum Import/Export Data
    Replies: 0
    Last Post: 02-23-2010, 01:29 PM
  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