Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: Current record

  1. #1
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80

    Unanswered: Current record

    Just a quick question... I have a textfield and I want it to show the number of current record and total records (f.ex. 10/400). Does anyone have code for it?

  2. #2
    Join Date
    Nov 2003
    Posts
    4

    Yeasy way

    Hi,

    try this

    Private Sub Form_Current()
    Me.textbox_name.Value = Me.CurrentRecord & "/" & Me.Recordset.RecordCount
    End Sub


    //Joakim

  3. #3
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80
    In what event should I use this code?

  4. #4
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    Originally posted by Sham81
    In what event should I use this code?
    In the current event of the form
    Saludos
    Norberto

  5. #5
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80
    Oh yeah... of course... thanks

  6. #6
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80
    Hmmm... doesn't seem to work. The field is empty, no matter what I do.

  7. #7
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    Originally posted by Sham81
    Hmmm... doesn't seem to work. The field is empty, no matter what I do.
    Yes there is an mistake in the code yhe property CurrentRecord is for a form and the property RecordCount is for open recordset object .
    Saludos
    Norberto

  8. #8
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80
    It's working now, but there's a new problem. In the first record it displays 1/1, although there are 442 records. After I move to next record it displays 2/442, so it's working fine after the first record.

  9. #9
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Exclamation Brouwsing records

    When brousing for the recordcount allways use



    ****************
    Rs.Movelast
    Rs.Movefirst
    ***************
    then do your actions/functions

  10. #10
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80
    Could you give me some kind of example? It would be easier for me to understand how it works if I see it in action

  11. #11
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Post Sample

    Public Sub Fill_Calculate_data(pForm As Form)
    With pForm
    DoEvents
    .DataCalculate.RecordSource = "SELECT * FROM Z_Items_History ORDER BY Date DESC"

    .DataCalculate.Refresh
    .DataCalculate.Recordset.MoveLast
    .DataCalculate.Recordset.MoveFirst
    DoEvents
    Do untilll .DataCalculate.EOF
    Debug.print .DataCalculate.Recordset(MyColumnName)
    .DataCalculate.movenext
    Loop
    End With
    End Sub

  12. #12
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80
    Thanks Marvels!

    My form is working now...

  13. #13
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80
    Another problem: When I push "new record"-button the text box displays 443/442. Is there a refresh-function or something that I could use?

  14. #14
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Wink hmmm

    thats strange,
    i know addnew makes a new row but if it isnt saved jet it shoud still be 422 / 422

    May be that coud be ok, so users can see that thy are adding a new record

    But you can do the following to solve it
    after the addnew you set

    Me.textbox_name.Value = Me.CurrentRecord & "/" & Me.Recordset.RecordCount + 1

    end after the rs.update
    you refresh it shoud be 423 / 423

  15. #15
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Exclamation by the way

    if the user cancels the update don't forget to refresh anyway

    this is because if you use the line
    Me.textbox_name.Value = Me.CurrentRecord & "/" & Me.Recordset.RecordCount + 1

    after the addnew
    it will still show 423 / 423
    and in fact you have 422 records because the user canceld the request

Posting Permissions

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