Code Causes Task Manager to Max Out

  • Thread starter Thread starter Tom \T\
  • Start date Start date
T

Tom \T\

Hello Everyone,

This code is contained within a Command button. The Command button is on an
Unbound Form. The Unbound Form allows the user to enter parameters into a
query in which a Report is based. The Command Button Previews a Report.

While SysCmd(acSysCmdGetObjectState, acReport, stDocName) = acObjStateOpen
Me.Visible = False
DoEvents
Wend
Me.Visible = True
If Err = 2501 Then
Err.Clear
End If

When the Report is displayed and the Unbound Form is set to Me.Visible =
False the Task Manager is maxed out. I know this because I commented out the
above code, compiled and then saved the code. I then previewed the report
and the Task Manager remained low.

I like the ability to hide the form but how can it be modified so that it
does not max out Task Manager.

Any help would be greatly appreciated.

Tom "T"
 
The code runs a loop that continues whileever the report is open. Even
though it includes a DoEvents to yield processor time to other
threads/tasks, the code is continually looping, so naturally it will consume
any spare processor cycles and keep the CPU busy.

Instead of constantly looping, would it be possible to simply set the form's
Visible property to No in the Open event of the report, and set it to Yes
again in the report's Close event?
 
Allen,

Thank You. I tried exactly what you said and it works! Happy New Year!

Tom "T"
 
Back
Top