I have a table whose data needs to be reset each time one of my forms loads. The form contains a subform that contains data from the database table that's being reset.
I've been trying to get it to reset in the Form_Open of the main form however it doesn't seem to affect the table - The old data remains there. Any ideas? I was wondering if it might be a timing issue, EG, the subform has already opened before the DELETE statement has executed?
Code:
Private Sub Form_Open(Cancel As Integer)
CurrentDb.Execute "DELETE from Temp_Shipping"
CurrentDb.Execute "INSERT INTO Temp_Shipping (PartID, Quantity, Anodized) SELECT PartID, 0, No FROM Parts"
CurrentDb.Execute "UPDATE Temp_Shipping INNER JOIN Parts ON Parts.PartID=Temp_Shipping.PartID SET Temp_Shipping.Anodized=Parts.GetsAnodized;"
End Sub
EDIT: There seems to be something odd when using Form_Open and Form_Close. For instance, Form_Close events don't trigger if I right-click the form tab and select "Close" however they do trigger if I use DoCmd.Close acForm. Any suggestions?