Hello programmers,
I have a form that when it exits it runs this code:
Private Sub Form_Close()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim i As Integer
Dim j As Integer
Dim stDocName As String
stDocName = "qryPickupSubPlusQnty"
Set db = CurrentDb
Set rs = db.OpenRecordset("tblPickupsSub", dbOpenDynaset)
If Me!frmPickupsOnCallSub![Quantity] > 1 Then
With rs
j = 1
For i = 1 To Me!frmPickupsOnCallSub![Quantity]
.AddNew
.Fields("PickupID"
= Me![PickupID]
.Fields("ContainerID"
= Me!frmPickupsOnCallSub![ContainerID]
.Fields("BarCode"
= Me!frmPickupsOnCallSub![BarCode]
.Fields("ContainerName"
= Me!frmPickupsOnCallSub![ContainerName]
.Fields("ContainerDescription"
= Me!frmPickupsOnCallSub![ContainerDescription]
.Fields("Quantity"
= 1
.Update
Select Case i
Case 4, 8, 12, 16: j = j + 1
End Select
Next i
End With
Set rs = Nothing
Set db = Nothing
Else
End If
DoCmd.OpenQuery stDocName
End Sub
The problem is that the data gets created for the last data row in the subform not all the information in the subform. How do I fix this?
I have a form that when it exits it runs this code:
Private Sub Form_Close()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim i As Integer
Dim j As Integer
Dim stDocName As String
stDocName = "qryPickupSubPlusQnty"
Set db = CurrentDb
Set rs = db.OpenRecordset("tblPickupsSub", dbOpenDynaset)
If Me!frmPickupsOnCallSub![Quantity] > 1 Then
With rs
j = 1
For i = 1 To Me!frmPickupsOnCallSub![Quantity]
.AddNew
.Fields("PickupID"
.Fields("ContainerID"
.Fields("BarCode"
.Fields("ContainerName"
.Fields("ContainerDescription"
.Fields("Quantity"
.Update
Select Case i
Case 4, 8, 12, 16: j = j + 1
End Select
Next i
End With
Set rs = Nothing
Set db = Nothing
Else
End If
DoCmd.OpenQuery stDocName
End Sub
The problem is that the data gets created for the last data row in the subform not all the information in the subform. How do I fix this?