View Full Version : Out of stack space error


Chunk
02-28-2005, 05:05 AM
I have this code:


Private Sub calcOrderStatus()

Dim numLinesAwaitingStock As Integer
Dim numLinesComplete As Integer
Dim qryResult As DAO.Recordset

If Not IsNull(Me.sup_order_number) Then

Set qryResult = CurrentDb.OpenRecordset("SELECT Count([sup_order_line_number]) AS [countOrderLineNums] FROM Supplier_order_line WHERE ([Supplier_order_line].[sup_order_number] = " _
& Forms("SupplierOrderEnquiry").sup_order_number _
& ") And ([Supplier_order_line].[order_line_status] = 'Awaiting delivery');")
numLinesAwaitingStock = qryResult!countOrderLineNums

Set qryResult = CurrentDb.OpenRecordset("SELECT Count([sup_order_line_number]) AS [countOrderLineNums] FROM Supplier_order_line WHERE ([Supplier_order_line].[sup_order_number] = " _
& Forms("SupplierOrderEnquiry").sup_order_number _
& ") And ([Supplier_order_line].[order_line_status] = 'Complete');")
numLinesComplete = qryResult!countOrderLineNums

qryResult.Close

If numLinesAwaitingStock > 0 Then

Me.numLinesAwaitingStock = "Incomplete"

ElseIf numLinesComplete > 0 Then

Me.numLinesAwaitingStock = "Complete"

Else

Me.numLinesAwaitingStock = "Cancelled"

End If

End If

End sub


When I do:

Call calcOrderStatus()

From a form event handler, I get:

"Out of stack space" error.

How can I fix this?

Thanks.

modest
02-28-2005, 07:11 AM
I'm not sure if any of these will fix your problems... but here are a list of somethings you can definitely try.

1) Make your function public.
2) Change integer variable "numLinesAwaitingStock" name to something else other than the object name on the form (this may confuse access)
3) Although your queries should work.. change Forms("SupplierOrderEnquiry").sup_order_number to Forms![SupplierOrderEnquiry].[sup_order_number].value
4) close the recordset at the end of the sub