?
Solved

Run-time error '28': Out of stack space

Posted on 2009-07-07
4
Medium Priority
?
263 Views
Last Modified: 2012-05-07
This line...

clsVendor.Name = sVendor

...produces this error...

Run-time error '28': Out of stack space

I've highlighted the offending line with a box of ***. Does anyone know what is causing this error?
'Code in worksheet module:
 
Private Sub CommandButton1_Click()
    
    Dim wkb1 As Workbook, wkb2 As Workbook
    Dim lRowCounter As Long, lColumnCounter As Long
    Dim sFullName1 As String, sFileName1 As String, sFullName2 As String, sFileName2 As String
    Dim sVendor As String
    Dim dTotalCost As Double, dTotalSales As Double
 
    'sFullName1 = "\\msfs05.lowes.com\DATA1\SHARE\Lognet\Channel Change Process\13. IP&E Planning\Templates\Template ProForma Comp\JBK Examples\Data Collection Fields_v13 Routine.xls"
    sFullName1 = "C:\Documents and Settings\dpark\Desktop\Data Collection Fields_v13 Routine.xls"
    sFileName1 = sGetFileName(sFullName1)
    
    'sFullName2 = "\\msfs05.lowes.com\DATA1\SHARE\Lognet\Channel Change Process\13. IP&E Planning\Templates\Template ProForma Comp\JBK Examples\2009 L&G Fall Equipment_Program Sheet.xls"
    sFullName2 = "C:\Documents and Settings\dpark\Desktop\2009 L&G Fall Equipment_Program Sheet.xls"
    sFileName2 = sGetFileName(sFullName2)
      
    'Make sure both workbooks open
    If bIsWorkbookOpen(sFileName1) Then
        Set wkb1 = Workbooks(sFileName1)
        wkb1.Activate
    Else
        Set wkb1 = Workbooks.Open(Filename:=sFullName1)
        wkb1.Activate
    End If
        
    If bIsWorkbookOpen(sFileName2) Then
        Set wkb2 = Workbooks(sFileName2)
    Else
        Set wkb2 = Workbooks.Open(Filename:=sFullName2)
    End If
    
'    Dim mcolVendors As New Collection
    
    lRowCounter = 20
    lColumnCounter = 2
    
    With wkb2.Worksheets("2009")
        Do Until IsEmpty(.Cells(lRowCounter, "B"))
            sVendor = .Cells(lRowCounter, "B").Value
            
            AddVendor sVendor, lRowCounter
            If mcolVendors(sVendor) Is Nothing Then
                AddVendor sVendor, lRowCounter
            End If
                        
            mcolVendors(sVendor).TotalCost = mcolVendors(sVendor).TotalCost + .Cells(lRowCounter, "N").Value
            mcolVendors(sVendor).TotalSales = mcolVendors(sVendor).TotalSales + .Cells(lRowCounter, "O").Value
        Loop
    End With
End Sub
 
'Code in standard module:
 
Sub AddVendor(sVendor As String, lRowCounter As Long)
    Dim clsVendor As CVendor
    With Workbooks("2009 L&G Fall Equipment_Program Sheet.xls").Worksheets("2009")
        Set clsVendor = New CVendor
***********************************************
**      clsVendor.Name = sVendor      **
***********************************************
        mcolVendors.Add clsVendor, sVendor
    End With
End Sub
 
'Code in class module
 
Private dSumCost As Double
Private dSumSales As Double
 
Property Let Name(sVendor)
    Name = sVendor
End Property
 
'Sum TotalCost values
Property Let TotalCost(dTotalCost As Double)
    TotalCost = TotalCost + dTotalCost
End Property
 
'Sum TotalSales values
Property Let TotalSales(dTotalSales As Double)
    TotalSales = TotalSales + dTotalSales
End Property
 
'Return TotalCost
Property Get TotalCost() As Double
    TotalCost = TotalCost
End Property
 
'Return TotalSales
Property Get TotalSales() As Double
    TotalSales = TotalSales
End Property
 
Public Function PercentMargin() As Double
    GetPercentMargin = (TotalSales1 - TotalCost1) / TotalSales1
End Function

Open in new window

0
Comment
Question by:ltdanp22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:ltdanp22
ID: 24796509
Additional Info:

The code enters and then re-runs this line until the Out of stack space error pops up...

Property Let Name(sVendor)
    Name = sVendor
End Property

Is Name a reserved word?
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 24796521
I think that we need to know more about what CVendor is. However, you should be aware that Out-of-stack space errors are usually caused by a runaway recursion loop.
0
 

Author Closing Comment

by:ltdanp22
ID: 31600715
syntax of property let was wrong. need to instantiate private variables and set them equal to argument
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24797494
Property Let Name(sVendor)
    Name = sVendor
End Property

means that on this line:
Name = sVendor

you call the property let method again... and again ... and again...

instead, it should assign to a class -level variable




private _Name as string 
Public Property Let Name(sVendor as string)
    _Name = sVendor
End Property 
Public Property Get Name as string
    Name = _Name
End Property

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month13 days, 8 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question