Show counter number in a text box on a form

  • Thread starter Thread starter SAC
  • Start date Start date
S

SAC

I'm running a loop and incrementing a counter.

I would like a form to display the counter as it progresses.

I've tried:

forms![Form1]![Text0] = intCounter + 1
forms![Form1].refresh
forms![Form1].setfocus

but this doesn't work.

Any ideas?

Thanks.
 
Use the DoEvents. From MS Access VB Help:
DoEvents Function Example (Microsoft Access)

The following example uses the DoEvents function to return control to the
operating system while a loop is executing. The DoEvents function always
returns 0.

Sub LongLoop()
Dim intI As Integer

For intI = 1 To 1500 ' Start loop.
If intI Mod 100 = 0 Then ' If loop has repeated
' 100 times.
DoEvents ' Yield to operating
' system.
Debug.Print intI
End If
Next intI ' Increment loop counter.
End Sub-- --Roger Carlson Access Database Samples:
www.rogersaccesslibrary.com Want answers to your Access questions in your
Email? Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L"SAC"
 
Thanks.

Roger Carlson said:
Use the DoEvents. From MS Access VB Help:
DoEvents Function Example (Microsoft Access)

The following example uses the DoEvents function to return control to the
operating system while a loop is executing. The DoEvents function always
returns 0.

Sub LongLoop()
Dim intI As Integer

For intI = 1 To 1500 ' Start loop.
If intI Mod 100 = 0 Then ' If loop has repeated
' 100 times.
DoEvents ' Yield to operating
' system.
Debug.Print intI
End If
Next intI ' Increment loop counter.
End Sub-- --Roger Carlson Access Database Samples:
www.rogersaccesslibrary.com Want answers to your Access questions in your
Email? Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L"SAC"
I'm running a loop and incrementing a counter.

I would like a form to display the counter as it progresses.

I've tried:

forms![Form1]![Text0] = intCounter + 1
forms![Form1].refresh
forms![Form1].setfocus

but this doesn't work.

Any ideas?

Thanks.
 
Got it! Thanks.

Klatuu said:
forms![Form1]![Text0] = intCounter + 1
forms![Form1].Repaint

SAC said:
I'm running a loop and incrementing a counter.

I would like a form to display the counter as it progresses.

I've tried:

forms![Form1]![Text0] = intCounter + 1
forms![Form1].refresh
forms![Form1].setfocus

but this doesn't work.

Any ideas?

Thanks.
 
Back
Top