Private Sub Command34_Click() 'DoCmd.SetWarnings False If Not (Recordset.EOF And Recordset.BOF) Then Recordset.MoveFirst 'Good habit Do Until Recordset.EOF = True DoCmd.OpenQuery "qryStockTransferDeductFrom" ' Deducts the quantity from QtyLoc in the ProdLocations Table. If DCount("*", "[ProdLocations]", "[ProductID] =" & Me.ProductID & " AND [LocID] =" & Me.LocID) > 0 Then DoCmd.OpenQuery "qryStockTransferAddTo" 'Updates QtyLoc in the ProdLocations Table If there is one already existing from the Dcount. Else DoCmd.OpenQuery "qryStockTransferAddAppend" 'Adds a record to ProdLocations Table if one doesn't already exist from the Dcount. 'Move to the next record. Don't ever forget to do this. Recordset.MoveNext Loop Else MsgBox "There are no records in the recordset." End If End If MsgBox "Finished looping through records." 'Recordset.Close 'Close the recordset 'Set Recordset = Nothing 'Clean up 'DoCmd.SetWarnings True End Sub
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
20 Experts available now in Live!