Hello programmers,
I have this code in a subform that is supposed to execute and stop at the end of subform data. This is the code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim i As Integer
Dim j As Integer
Dim stDocName As String
stDocName = "qryPickupSubPlusQnty"
'Do
Set db = CurrentDb
Set rs = db.OpenRecordset("tblPickupsSub", dbOpenDynaset)
'If Forms![frmPickupsOnCall]![frmPickupsOnCallSub]![ContainerID] <> "" Then
If Me!frmPickupsOnCallSub![Quantity] > 1 Then
With rs
.MoveFirst
Do
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
.MoveNext
Loop Until .EOF
End With
Set rs = Nothing
Set db = Nothing
Else
End If
'End If
'Loop Until Form_frmPickupsOnCallSub!ContainerID.Value = ""
DoCmd.OpenQuery stDocName
End Sub
Where did I go wrong?
I have this code in a subform that is supposed to execute and stop at the end of subform data. This is the code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim i As Integer
Dim j As Integer
Dim stDocName As String
stDocName = "qryPickupSubPlusQnty"
'Do
Set db = CurrentDb
Set rs = db.OpenRecordset("tblPickupsSub", dbOpenDynaset)
'If Forms![frmPickupsOnCall]![frmPickupsOnCallSub]![ContainerID] <> "" Then
If Me!frmPickupsOnCallSub![Quantity] > 1 Then
With rs
.MoveFirst
Do
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
.MoveNext
Loop Until .EOF
End With
Set rs = Nothing
Set db = Nothing
Else
End If
'End If
'Loop Until Form_frmPickupsOnCallSub!ContainerID.Value = ""
DoCmd.OpenQuery stDocName
End Sub
Where did I go wrong?