Minimize form will not re-display

D

Darryle

One form, one button to process, I display a record counter as records are
processed. The process can take 2 hours.

When I press the button to process, vb code takes over reading several db
tables and outputs a text file. As each record is processed I increment a
record count that I display on the form.

When I mimimize this process (form) and go do something else on my
workstation like read my email, the screen will not come back when I try to
return via the task bar. The form will come back up when I call the msgbox
function.

Can you give me suggestions that will make the form re-display after it has
been minimized?

Thank you.
 
W

Wayne Morgan

It is probably just busy processing what you've asked it to. Try adding

DoEvents

in the loop you are running through to release control momentarily to do
things such as update the form. If that isn't sufficient, you may also need
to Repaint the form.

Me.Repaint
or if the loop is running from another form
Forms!MyForm.Repaint

You may also find the following useful so that if the form is minimized, you
don't have to do anything. This would be placed in a standard module.

Private Type POINTAPI
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type WINDOWPLACEMENT
Length As Long
flags As Long
showCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As
Long, lpwndpl As WINDOWPLACEMENT) As Long
Dim Rectan As RECT

Public Function IsMinimized(lngHandle As Long) As Boolean
Dim WinEst As WINDOWPLACEMENT
Dim rtn As Long
WinEst.Length = Len(WinEst)
'get the current window placement
rtn = GetWindowPlacement(lngHandle, WinEst)
IsMinimized = (WinEst.showCmd = 2)
End Function

To call the function, send the hWnd of the form in question.

Example:
IsMinimized(Me.hWnd)
or
IsMinimized(Forms!MyForm.hWnd)

The function will return True of False. A 2450 error will be generated by
the calling code if the form isn't open.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top