Reply To: ghostriderofthenite Ultimate Bot project


thing im exploreing some these
Microsoft Access tips: VBA Traps: Working with Recordsets

Microsoft Access tips: VBA Traps: Working with Recordsets

Common mistakes developers make when working with Recordsets in a Microsoft Access database

5. MoveNext without testing EOF

A MoveNext may take you to the end of the recordset (EOF) or a MovePrevious to the beginning of the recordset (BOF). Failure to test for these conditions means your code works for most cases, but generates an error one day when the last/first record is accessed.

The problem is prevalent when you have another exit condition in mind for your loop, so you are not thinking of EOF. Test for EOF (or BOF if moving backwards) before checking the real exit condition for your loop.

Use this construct for looping through Access recordsets:

    Do while Not rst.EOF
        If rst![MyField] <> Something Then  'The real loop exit condition.
            Exit Do
        End If
        ' Rest of your code here.


Another solution would be to use a timer control. You could set the time to 30000 msecs
and enable the timer. In the Timer_Timer() event you will disable the timer.
In your code you need a line to wait for the disabled timer.
Assume Timer1 added to your form

Private Sub Timer1_Timer()
  Timer1.Enabled = False
End Sub

‘in your code loop

While Timer1.Enabled: DoEvents: Wend ‘wait for the timer to expire

or this possibily

For the sake of a complete set of solutions:

If you’re using vb6 in an application environment (like excel), you can use

Application.OnTime (now + TimeValue(“00:00:30”)), “ProcedurePart2”

to call a procedure (with no parameters) after 30 seconds without locking up the application or consuming CPU power.

This would, for instance, work in any VBA environment. Depending on the nature of your VB6 app (standalone vs add-on), this option may be available to you.

Public Sub delay(PauseTime as integer)
    Dim start As single
    start = Timer  
   Do While Timer < start + PauseTime
    If (Timer < start) Then 'midnight crossover
        start = start - (86400 + 1)
    End If  
    DoEvents   ' Yield to other processes.

End Sub