J
JimS
I'm iterating through a list box, adding items to a header-detail structure.
The code is in a class module (clsPicklist). I'm getting an error saying the
maximum number of pending updates exceeded. I'm sure I'm doing something
simple wrong. Herewith the code:
Private Sub btnOneTouch_Click()
Dim lngPicklistID As Double
PickList.BoMID = lngBoMID 'Set the Bill of Materals ID
lngPicklistID = PickList.NewList 'Create a new Header Record using
BoMID
Dim i As Long
For i = 0 To Me.lbBoM.ListCount - 1
PickList.AddNewDetail CLng(Me.lbBoM.Column(0, i)),
CDbl(Me.lbBoM.Column(1, i))
Next i
End Sub
[Inside the class module...]
Private Sub Class_Initialize()
Debug.Print "clsPickList Initialized at " & Now()
rstPickListMaster.Open "tblPickListMaster", CurrentProject.Connection,
adOpenDynamic, adLockBatchOptimistic
rstPickListDetail.Open "tblPickListDetail", CurrentProject.Connection,
adOpenDynamic, adLockBatchOptimistic
End Sub
..
..
..
Public Function NewList()
With rstPickListMaster
' Debug.Print !picklistid
.AddNew
!PicklistBoMID = m_lngBoMID
!PicklistDropLocation = ""
!PicklistNotifyNbr = ""
!PicklistDescription = ""
!PicklistPriority = "N"
.Update
Debug.Print !picklistid
NewList = !picklistid
End With
End Function
Public Function AddNewDetail(BoMDetailID As Long, Quantity As Double) As Long
With rstPickListDetail
.AddNew
!PLPicklistid = rstPickListMaster!picklistid
!PLBoMDetailID = BoMDetailID
!PLDetailQtytoPick = Quantity
.Update
AddNewDetail = !pldetailid
Debug.Print "Added " & !pldetailid
End With
End Function
The code is in a class module (clsPicklist). I'm getting an error saying the
maximum number of pending updates exceeded. I'm sure I'm doing something
simple wrong. Herewith the code:
Private Sub btnOneTouch_Click()
Dim lngPicklistID As Double
PickList.BoMID = lngBoMID 'Set the Bill of Materals ID
lngPicklistID = PickList.NewList 'Create a new Header Record using
BoMID
Dim i As Long
For i = 0 To Me.lbBoM.ListCount - 1
PickList.AddNewDetail CLng(Me.lbBoM.Column(0, i)),
CDbl(Me.lbBoM.Column(1, i))
Next i
End Sub
[Inside the class module...]
Private Sub Class_Initialize()
Debug.Print "clsPickList Initialized at " & Now()
rstPickListMaster.Open "tblPickListMaster", CurrentProject.Connection,
adOpenDynamic, adLockBatchOptimistic
rstPickListDetail.Open "tblPickListDetail", CurrentProject.Connection,
adOpenDynamic, adLockBatchOptimistic
End Sub
..
..
..
Public Function NewList()
With rstPickListMaster
' Debug.Print !picklistid
.AddNew
!PicklistBoMID = m_lngBoMID
!PicklistDropLocation = ""
!PicklistNotifyNbr = ""
!PicklistDescription = ""
!PicklistPriority = "N"
.Update
Debug.Print !picklistid
NewList = !picklistid
End With
End Function
Public Function AddNewDetail(BoMDetailID As Long, Quantity As Double) As Long
With rstPickListDetail
.AddNew
!PLPicklistid = rstPickListMaster!picklistid
!PLBoMDetailID = BoMDetailID
!PLDetailQtytoPick = Quantity
.Update
AddNewDetail = !pldetailid
Debug.Print "Added " & !pldetailid
End With
End Function