Ok I am having trouble with this code and placing the End If. I have 2 If Statements. One for the Loop and one for the Dcount.
If everything I understand is true then.... I have to have the End If for the loop after LOOP.
But I have a If statement for the Dcount in the middle of that.
Where do I place the Dcount End If so it doesn't mess with the If Loop Statement?
If I place it after the Loop won't it carry over on the next records Loop?
Private Sub Command34_Click()
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.
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.
MsgBox "There are no records in the recordset."
MsgBox "Finished looping through records."
'Recordset.Close 'Close the recordset
'Set Recordset = Nothing 'Clean up