472,133 Members | 1,033 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,133 software developers and data experts.

Command Button not displaying on form after a reload

I have a form with a form in my application.

When the form is reloaded, a particular command button refuses to display even when there was no command to hide it. It only shows a blank shape where the button is supposed to be.

Has anybody experienced this in the past.

Kindly help me out with this as it does the same on clients' machines after compillation and deployment.
Attached Images
File Type: jpg form with button.jpg (26.7 KB, 382 views)
File Type: jpg form without button.jpg (28.0 KB, 354 views)
Dec 26 '11 #1
11 3454
8,435 Expert 8TB
I think we need you to provide us with some more background info. For instance...
  • What version of VB are you using?
  • What exactly do you mean by "reloading" the form?
  • What does a "form with a form" mean?
Dec 27 '11 #2
Thank you Killer42
Im using VB6
by reloading, i mean unloading the form and then loading the form again to clear the data entered bythe user,thereby making the form blank and ready for data entry again

unload me

"form with a form": this is a typo error. please pardon me for that, i meant "form with a command button".
Dec 27 '11 #3
8,435 Expert 8TB

Not sure exactly what the problem is, but I must say it sounds like a bad idea to unload a form and then show it again, from within the form. At a guess, this could be causing VB some confusion. The unload command is supposed to entirely remove the form (including all code) from memory. Not sure how things work if you're still "in" the form executing code afterward. You're effectively telling VB "erase this code which I'm executing". Ugh.

As a general rule, I'd advise against using the statement Unload Me unless it's the last one executed by "Me".

Best I can think of right now is to either:
  • do this process from outside the form, or
  • create a sub that clears all the data, and call that instead of reloading the form.
Oh, one more thing you might try first, since it's quicker and easier. Try fiddling with the form's ClipControls and AutoRedraw properties (just in the editor I mean, not your code), to see whether they make a difference. But make sure you make a note of what they are beforehand, so you can put them back afterward.
Dec 27 '11 #4
Hi Killer42
I had tried clipcontrols and AutoRedraw earlier. I think the issue is related to the fact that the button's style was set to graphics. I needed to set a back color for the button to let user identify it easily (these are old people with very little knowledge of the computer).

Now, I changed style to default and it works fine.
I still need to find a way to change the back color of that button without losing it on the form.

For the unload and reload thing.

Because the amount of items to be cleared are so much and there are so many other routines to be called after each data submission, it became difficult to just clear the form without unloading (the process is an online real time process which involves so many symultaneous complex database activities). And since the time difference is just in nanoseconds on a 486, I thought it will make no difference on a pentium or higher.
However, the form.show is called from an external procedure not within the form.

Thanks once again.
Dec 27 '11 #5
This might sound kind of silly, but perhaps adding
Expand|Select|Wrap|Line Numbers
  1. in Form_Load:
  2. DoEvents
  3. Me.Show
This _might_ solve this visual glitch.
Dec 27 '11 #6
Thanks BigPapa,
The above code did not even solve the problem.

I think there is an issue with the graphics style of the command button. It works well if set to standard. Issue arises when style is set to graphics.
Dec 27 '11 #7
While this isn't a fix, but rather a workaround, you might try keeping it a standard style and setting it to graphical via code after the form is loaded. Unfortunately, I have been unable to recreate the issue on my system and have never heard of this issue.

Please keep us updated on this, we're always here to help!

PS - Have you also updated VB6 with the latest service pack?
Dec 27 '11 #8
8,435 Expert 8TB
Yes, I'm afraid I'm pretty much out of ideas. It's really tough to investigate something like this without being able to reproduce it.

All I can think of is experimentation with things like the button's .Refresh method, switching between standard & graphic modes, switching visibility on and off, and anything else you can come up with. Including switching style after the form's loaded, as BigPapaN0z suggested.
Dec 28 '11 #9
8,435 Expert 8TB
P.S. One more thing I was wondering about. Is there anything else which is in front of the button, but not currently visible?

In any case, another "just in case" option you might try is using Format | Order | Bring to Front to bring this button to the front of the Z-order, just in case something is obscuring it.
Dec 28 '11 #10
Thank you guys for your help tips.
The style property is actually read only at run time so that is not an option.

The button has nothing in front of it but it is inside a frame as other controls. The other controls do not have any issues and I see no reason so far why this is happening,perhaps because it is the most active button and one that closes the form, because all other buttons are set as graphical also.
For now, I have decided to leave it as default so I can just meet my dead line. I shall keep working around until I find a solution. Once I do, you'll know about it.

Thank you all once agai. This family is a good one.
Dec 28 '11 #11
8,435 Expert 8TB
Sorry we couldn't help you solve that one.

And yes, please let us know if you do find a solution, so it'll be here if anyone else needs it.

P.S. If it's in a frame, the .ClipControls property of the frame applies to it, not the form. No idea whether this will help.
Dec 28 '11 #12

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Colin | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.