Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2006
    Posts
    4

    Unanswered: Counter on a form

    Hi,

    I am a fench guy ... so my english 'll be poor ...
    I want to add a counter in a form.
    This counter will display the current record number (counter = counter +1 ..)
    I write a code in access 2000 but it'sn't working.
    I try different kind of program ... nothing work !!
    When I stop my process <CTRL> + Break => the label, with the counter, is displayed in the form with thr right value.
    If I use the debugger (F8) and check my code step by step ... it's working !
    But I launch the program (update of some record, deleting some other, ....) the value of counter in the form still the same.
    I also try with the Timer/form ... still the same.

    Any ideas ....?

    Thanks for prompt answer.

    Bye.

    Code :
    Me.CPTTV.Visible = False (start of loop)
    Me.CPTTV.Caption = CPT
    CPT = CPT+1
    Me.CPTTV.Visible = True (end of loop)

    this code is in a while/wend loop when updating records

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    Without knowing too much about the rest of your code, maybe try...

    Me.CPTTV.Visible = False (start of loop)
    CPT = Me.CPTTV.Caption
    Me.CPTTV.Caption = CPT+1
    Me.CPTTV.Visible = True (end of loop)


    HTH
    Me.Geek = True

  3. #3
    Join Date
    Aug 2006
    Posts
    4

    Here can you find ... part of my coding

    Compteur_Record = 0
    Cpt = 0

    Me.CPTTV.Caption = CPT
    Me.CPTTV.Visible = False

    If Display_msg = 6 Then

    Set dbsST = CurrentDb

    Set rsST = dbsST.OpenRecordset("xxxxTable", dbOpenDynaset)
    Set rsST1 = dbsST.OpenRecordset("xxxxTable", dbOpenDynaset)
    Set rsST2 = ............

    Set conCmd = Application.CurrentProject.Connection

    stSql = "SELECT * FROM [xxxTable] WHERE ((Left([CLM_CODE],4)< " & Year_Archive & ")) ORDER BY CLM_CODE DESC;"
    stSql1 = "SELECT * FROM [xxxxxxxTable] WHERE ((Left([CLM_CODE],4)< " & Year_Archive & ")) ORDER BY CLM_CODE DESC;"
    stSql2 = .............

    Set rstCmd = CreateObject("ADODB.Recordset")
    Set rstCmd1 = CreateObject("ADODB.Recordset")
    Set rstCmd2 = .........

    rstCmd.Open stSql, conCmd, 1
    rstCmd1.Open stSql1, conCmd, 1
    ......

    Compteur_Record = rstCmd.RecordCount()
    Cpt = 0
    Num_Cmd = 0

    While (Cpt < Compteur_Record)
    Num_Cmd = Num_Cmd + 1

    action on records .......


    rstCmd1.MoveNext

    Cpt = Cpt + 1
    Me.CPTTV.Caption = Cpt
    Me.CPTTV.Visible = True
    Wend

    rstCmd.Close
    rstCmd1.Close
    rsST.Close

    Set rstCmd = Nothing
    Set conCmd = Nothing

    End If
    ......

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    are you sure you want to do this?
    you will introduce overhead just to update a counter - does your user care about each increment?
    consider doing a screen update every XX records so that the user gets some feedback every 2....5 seconds.

    if Compteur_Record mod XX = 0 then
    me.repaint
    endif

    will update the display every XXth record.

    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    forgot to read your code - sorry.

    Cpt = Cpt + 1
    Me.CPTTV.Caption = Cpt
    if cpt mod XX = 0 then
    me.repaint
    endif

    izy
    currently using SS 2008R2

  6. #6
    Join Date
    Aug 2006
    Posts
    4
    Hi guys ...

    Thanks for replying to my post !!
    I have try all your suggestions .... nothing work ...
    When I try to move my form ... the hourglass appears and I can't do anything else ....
    <CTRL>+Break works ... and then the form show me the counter with the right value.

    Thanks .....

  7. #7
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    so it's time to bring out the big guns:

    Cpt = Cpt + 1
    Me.CPTTV.Caption = Cpt
    if cpt mod XX = 0 then
    me.repaint
    doevents
    endif

    izy
    currently using SS 2008R2

  8. #8
    Join Date
    Aug 2006
    Posts
    4
    Hi guys ... you are doing great and good jobs !!!

    Thanks to izyrider ..... the DoEvent command works perfect !!!

    Have a nice day.

    Bye and thanks for all.

Posting Permissions

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