ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unloading userforms (https://www.excelbanter.com/excel-programming/389286-unloading-userforms.html)

Oggy

Unloading userforms
 
Hi

I have wrote a few macros to open up a userform and when finished,
with a comand boutton open a different userform. I keep getting an
error 28 after running them for a little while. I have recreated the
problem by writing the following code to establish the loading of
userforms is the problem. has anyone got any suggestions on how i can
resolve the problem.

Thanks in advance

Addy




Private Sub CommandButton1_Click()
Unload userform2
Set userform2 = Nothing
Run "a"
End Sub



Sub a()
userform1.Show
Unload userform1
Set userform1 = Nothing
End Sub


Private Sub CommandButton1_Click()
Unload userform1
Set userform1 = Nothing
Run "b"
End Sub

Sub b()
userform2.Show
Unload userform2
Set userform2 = Nothing
End Sub


RB Smissaert

Unloading userforms
 
It looks you have to keep better track of which forms are loaded or not or
avoid the error by doing On Error Resume Next.

RBS

"Oggy" wrote in message
oups.com...
Hi

I have wrote a few macros to open up a userform and when finished,
with a comand boutton open a different userform. I keep getting an
error 28 after running them for a little while. I have recreated the
problem by writing the following code to establish the loading of
userforms is the problem. has anyone got any suggestions on how i can
resolve the problem.

Thanks in advance

Addy




Private Sub CommandButton1_Click()
Unload userform2
Set userform2 = Nothing
Run "a"
End Sub



Sub a()
userform1.Show
Unload userform1
Set userform1 = Nothing
End Sub


Private Sub CommandButton1_Click()
Unload userform1
Set userform1 = Nothing
Run "b"
End Sub

Sub b()
userform2.Show
Unload userform2
Set userform2 = Nothing
End Sub



merjet

Unloading userforms
 
Each procedure goes with which UserForm?

Run "a" doesn't work for me. 'Call a' or 'a' (w/o the quotes) does.

You don't have to Unload a Userform. You can use Hide if you may want
to show it again.

It might help to say what you want to do.

Merjet



Oggy

Unloading userforms
 
On 12 May, 13:26, merjet wrote:
Each procedure goes with which UserForm?

Run "a" doesn't work for me. 'Call a' or 'a' (w/o the quotes) does.

You don't have to Unload a Userform. You can use Hide if you may want
to show it again.

It might help to say what you want to do.

Merjet


Thanks

I have written an estimating system where the user puts the infomation
into a spreadsheet via a userform. To make it easier for the user i
have 1 userform to enter the parts details, i userform to enter the
materials details and finally 1 userform for the labour details, this
then returns to a menu which is also a userform. My problem is that i
can only enter about 30 parts etc... then it will error 28 memory
stack is full. i have found the problem is the loading/unloding
userforms.

Addy


Peter Grebenik

Unloading userforms
 
If you examine the call stack (go into debug mode then use Ctrl-L) you
will see that the problem is not with loading and unloading the forms,
but because your "a" and "b" procedures get called recursively and
never terminate.

Peter Grebenik


Oggy

Unloading userforms
 
On 12 May, 14:01, Peter Grebenik wrote:
If you examine the call stack (go into debug mode then use Ctrl-L) you
will see that the problem is not with loading and unloading the forms,
but because your "a" and "b" procedures get called recursively and
never terminate.

Peter Grebenik


Hi

I have taken your advise and have now not used the a & b procedures
and now switch from one userform to another and i have found that when
i switch they do not unload from the memory stack and after a while i
still get the error 28.

Is there a way of stopping the buildup in the memory or am i asking to
much?

thanks


Peter Grebenik

Unloading userforms
 
Without seeing the code, I don't know.

Have you thought of using a multipage control on your userform to get
around the problem of constantly loading and unloading forms?

Peter Grebenik



All times are GMT +1. The time now is 02:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com