Show 0

C

Craig Coope

Hi,

I'm trying to work out my out of stack space problem and I'm trying to
load my forms by using

form1.show 0 and
form1.show vbModeless

Neither of them work. I just get a "wrong number of arguments or
invalid property assignment" message...

I'm using Excel 97...
 
C

Craig Coope

This option was added in xl2k. You don't get a choice in xl97.

Looks like I'll have to find another work around :eek:(

I got this from MS support website

' Form1:
Sub Form_Click ()
' MsgBox STR$(FRE(-2))
Unload Form1
Form2.Show 1
End Sub

' Form2:

Sub Form_Click ()
' MsgBox STR$(FRE(-2))
Unload Form2
Form1.Show 1
End Sub


It says that the above will cause an out of stack space error and it
seems that my forms are the same. What would you do to the above code
to stop this. It says on the support site that instead of calling your
next form from the current form you could have one form that initially
calls all the forms....I'm not too sure how to implement this
exactly..
 
D

Dave Peterson

I'm not sure what you're doing, but maybe you could create a public variable and
determine if the next userform should be shown based on what happened in the
first userform.

I put this in a General Module:

Option Explicit
Public OkToContinue As Boolean
Sub testme()
OkToContinue = False
UserForm1.Show
If OkToContinue = True Then
UserForm2.Show
End If
End Sub


I put this behind Userform1:

Option Explicit
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()
OkToContinue = True
Unload Me
End Sub
Private Sub UserForm_Initialize()
Me.CommandButton1.Caption = "Cancel"
Me.CommandButton2.Caption = "Ok"
End Sub

===
So each userform is called from a general module--and the public variable
determines if the next userform should be called at all.

But if you're showing lots of userforms, have you thought of using one userform
with multipages? Kind of like what you see in the Tools|Options dialog.
 
C

Craig Coope

I'm not sure what you're doing, but maybe you could create a public variable and
determine if the next userform should be shown based on what happened in the
first userform.

I put this in a General Module:

Option Explicit
Public OkToContinue As Boolean
Sub testme()
OkToContinue = False
UserForm1.Show
If OkToContinue = True Then
UserForm2.Show
End If
End Sub


I put this behind Userform1:

Option Explicit
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()
OkToContinue = True
Unload Me
End Sub
Private Sub UserForm_Initialize()
Me.CommandButton1.Caption = "Cancel"
Me.CommandButton2.Caption = "Ok"
End Sub

===
So each userform is called from a general module--and the public variable
determines if the next userform should be called at all.

But if you're showing lots of userforms, have you thought of using one userform
with multipages? Kind of like what you see in the Tools|Options dialog.

Thanks for the info...

Basically I have coded a load of forms that inputs job start and
finish times into a sheet. Pretty simple concept and I have got it all
to work apart from this out of stack space error.

There are forms like Workers (with a list of name buttons), Start work
form (with work amount etc on it), finish work form with a big red
stop button on it! and a time lost form where users input time lost
for the job.

So the forms go like this..

Workers>Start Work>Workers>Finish Work>time lost>Workers and so on...

So at the end of each form (on commandbutton click) it says something
like

me.hide
*nextform*.show

end sub

It works fine but looks like each of these is staying in call stack
and eventually after a few hours of use it is causing an out of stack
space error. The only way to get around this error thus far has been
to exit "X" the forms and restart them (thus clearing the stack- I
assume)...

The MS supportsite said a way to get around this is to use show 0 or
show Vbmodeless (neither of which work with Excel 97).
 
D

Dave Peterson

I still like the idea of using multipages -- in fact, you could make it work
like a wizard (think data|text to columns) -- so that you only enable then next
button when all the input on that page is filled out. Then the next page is
shown and the previous page is hidden.

But I guess I don't understand why the previous suggestion didn't work.

Just a bunch of code in a general module that shows one form after another. If
you don't need to check to see if you should continue, then you don't need that
"oktocontinue" stuff.
 
Top