Hello programmers,
I am having a terrible time with trying to use the dbOpenSnapshot. Here is a code and please feel free to correct the many mistakes I made:
Private Sub Form_Close()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set rs = Me.Recordset
Dim i As Integer
Dim j As Integer
Dim rec As Recordset
Dim stDocName As String
Dim strSQL As String
stDocName = "qryPickupSubPlusQnty"
strSQL = "Select * FROM tblPickupsSub Where [PickupID] = Me![PickupID]"
Set db = CurrentDb
Set rs = db.OpenRecordset("tblPickupsSub", dbOpenDynaset)
Set rec = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
rec.MoveFirst
While Not rec.EOF
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
'rs.MoveNext
'Ends the With Area above
End With
'Interior part of calculating Quantity
Else
'End of Interior Part of Calculating Quantity
End If
rec.MoveNext
Wend
rs.Close
Set rs = Nothing
Set db = Nothing
DoCmd.OpenQuery stDocName
End Sub
I am having a terrible time with trying to use the dbOpenSnapshot. Here is a code and please feel free to correct the many mistakes I made:
Private Sub Form_Close()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set rs = Me.Recordset
Dim i As Integer
Dim j As Integer
Dim rec As Recordset
Dim stDocName As String
Dim strSQL As String
stDocName = "qryPickupSubPlusQnty"
strSQL = "Select * FROM tblPickupsSub Where [PickupID] = Me![PickupID]"
Set db = CurrentDb
Set rs = db.OpenRecordset("tblPickupsSub", dbOpenDynaset)
Set rec = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
rec.MoveFirst
While Not rec.EOF
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
'rs.MoveNext
'Ends the With Area above
End With
'Interior part of calculating Quantity
Else
'End of Interior Part of Calculating Quantity
End If
rec.MoveNext
Wend
rs.Close
Set rs = Nothing
Set db = Nothing
DoCmd.OpenQuery stDocName
End Sub