So I'm new to access and I keep getting this "catastrophic error" when
running this function. I my mind, all I'm doing is a nested for each
loop with RecordSets Vs collections.
The kicker is, this string will work fine:
' curLine = "call AddBom(""" + inParent + """, """ + curChild +
""",""" + curQty + """)"
But this one give me a "catastrophic error"
'curLine = "call AddBom(""" + inParent + """, """ + curChild +
""",""" + curQty + """,""" + curSeq + """,""" + curPhantom + """)"
I've tried removing all the additional ""'s to no avail. Any ideas?
Thank you, thank you, thank you.
'partial code -- calls problem function
If Not rsAllParents.EOF Then rsAllParents.MoveFirst
Do While Not rsAllParents.EOF
DoEvents
If (rsAllParents!PartNum <> vbNullString) Then
Call CreateFinalOutput(rsAllParents!PartNum, _
rsAllParents!MakeOrBuy)
End If
rsAllParents.MoveNext
Loop
rsAllParents.Close
Public Function CreateFinalOutput(inParent As String, inMOBY As
Integer)
Dim rsChildren As ADODB.Recordset
Dim rsAutoBOMtemplate As ADODB.Recordset
Dim rsAutoBOMtemplate2 As ADODB.Recordset
Dim db As Database
Dim rsAdd As ADODB.Recordset
Dim OutputList As New Collection
Dim sqlcmd As String
Dim curParent As String
Dim curChild As String
Dim curQty As String
Dim curLine As String
Dim curSeq As String 'Make or Buy - Yes? sequence makes as
990's in BOM
Dim curPhantom As String 'is assembly? then code as phantom in BOM
curLine = ""
curParent = ""
curChild = ""
curQty = ""
curSeq = ""
curPhantom = ""
Set rsChildren = New ADODB.Recordset
Set rsAutoBOMtemplate = New ADODB.Recordset
Set rsAutoBOMtemplate2 = New ADODB.Recordset
Set rsAdd = New ADODB.Recordset
Set db = Application.CurrentDb
'Select items to drive loop
sqlcmd = "SELECT * " & _
"FROM tblOutput where Parent = '" & inParent & "'"
rsChildren.Open sqlcmd, CurrentProject.Connection, adOpenKeyset,
adLockOptimistic
If Not rsChildren.EOF Then rsChildren.MoveFirst
Do While Not rsChildren.EOF
curQty = rsChildren!Quantity
curChild = rsChildren!Child
isAssy = rsChildren!isAssy
'If (isAssy) Then
'curPhantom = "p"
'End If
'If (inMOBY = 12) Then 'see ECN.mdb tblTypeDetail [ID 12 =
Make]
' curSeq = "990"
'End If
'curLine = "call AddBom(""" + inParent + """, """ + curChild +
""",""" + curQty + """,""" + curSeq + """,""" + curPhantom + """)"
curLine = "call AddBom(""" + inParent + """, """ + curChild +
""",""" + curQty + """)"
sqlcmd = "insert INTO tblFinalOut (FunCalls) " & _
" VALUES (" & _
"'" & Replace(curLine, "#", "") & "')"
rsAdd.Open sqlcmd, CurrentProject.Connection, adOpenKeyset,
adLockOptimistic
rsChildren.MoveNext
Loop
rsChildren.Close
Set db = Nothing
End Function