Form does not disappear

  • Thread starter Thread starter George
  • Start date Start date
G

George

Project has two forms: formMain and formHelp.

formMain has two buttons:
"Help" button with code formHelp.Show
"Hide" button with code Me.Hide

formHelp has a "Close" button with code Unload Me

When formMain first shows I can move it around with no trail in the
background.

Two problems occur when formHelp shows:
When I move it around, it leaves a trail.

When I press formHelp's Close button, formMain appears but formHelp
(larger than formMain) still shows in the background. When I now move
formMain around, it also leaves a trail.

The same problems occur if I close formHelp with the red X close.
I get the impression something is wrong with formHelp.

If I click formMain's Hide button, both forms and their trails
disappear.

An earlier version does not have this problem; I don't know what caused
the change.

I've tried these ideas from another post:
(1) move code from form module to code module.
(2) insert Application.ScreenUpdating toggle.

Sub HelpShow()
formHelp.Show
Application.ScreenUpdating = False
Application.ScreenUpdating = True
End Sub

Sub HelpClose()
Unload formHelp
Application.ScreenUpdating = False
Application.ScreenUpdating = True
End Sub

These did not resolve the problem.

I have XP and Excel 2000.

Thanks,
George
 
when you call formHelp.Show

Make it Modeless (i.e. can be moved)

Try this:


formHelp.Show vbModeless
instead of formHelp.Show
 
Chip,
The primary goal was not to move the Help form. I described the two
symptoms as unusual behavior only to indicate a problem.
I've done some testing (showing more interesting odd things) and found
a resolution.

Background on what I'm trying to do:
Help sheet has information that goes into Help form ListBoxes.
Top LB has subject names. When user clicks on a subject, lower LB
displays the details for that subject.
Help sheet is "xlVeryHidden" away from user.

In Help form Activate sub in Help form module, code activates sheet
Help, calls a sub that has a WorksheetFunction to get the last row of
the active sheet, then copies info from the Help sheet to the top LB.

I set a Breakpoint at top of this Activate sub. I get different results
if I F5 at that point or if I F8 through it.
F5 results:
Data from sheet Help is copied into the LB. When I move the form it
leaves a trail in the background. If the Excel window is maximized, the
Help form does not disappear when it's closed.

F8 results:
Even though Help sheet is activated, sName = activesheet.name shows the
only visible sheet. The WorksheetFunction provides info for that
visible sheet and data is not copied into the LB. When the Help form
closes, it disappears.

Question#1. Why does code act differently depending on F5 or F8?
Question#2. In F8, if Help sheet.activate does not work, why isn't
there an error message?

If Help sheet is made visible, both F5 and F8 provide the same expected
good results; the two initial problems - form leaving a trail and Help
not disappearing - do not occur.

Therefore the problems were apparently caused by code working with a
hidden sheet that was activated.

But I don't want to have sheet Help visible.

Here is how I resolved the problem:
In the Activate sub, removed Help sheet.activate, which didn't work in
F8 mode.
Modified code to work with a specific range in Sheet Help.
Modified the WorksheetFunction to deal with a specific range (workbook
name and sheet name are arguments) instead of assuming the active
sheet.
With sheet Help 'xlVeryHidden', results are OK in either F5 or F8 mode.

George
 

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

Back
Top