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

Posted on 2009-07-07
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 = "\\\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 = "\\\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)



        Set wkb1 = Workbooks.Open(Filename:=sFullName1)


    End If


    If bIsWorkbookOpen(sFileName2) Then

        Set wkb2 = Workbooks(sFileName2)


        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


    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

Question by:ltdanp22
  • 2

Author Comment

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?
LVL 76

Accepted Solution

GrahamSkan earned 500 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.

Author Closing Comment

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

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


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

867 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now