Expand|Select|Wrap|Line Numbers
- Dim strSQL As String
- Dim strSQL2 As String
- Dim Reply As String
- Dim db As Database
- Dim rst As Recordset
- Dim SeqItemNo As Integer
- DoCmd.SetWarnings False
- Set db = CurrentDb()
- Set rst = db.OpenRecordset("SELECT * FROM preordlin")
- DoCmd.Save
- DoCmd.GoToRecord , , acFirst
- SeqItemNo = 1
- Do
- rst.Edit
- Me.Requery
- rst!StkID = DLookup("[StkID]", "stkmas", "[StkShortDesc] ='" & rst!StkShortDesc & "'")
- If IsNull(rst!StkID) Then
- Reply = MsgBox("There are Stock Items present that do not belong to our existing Stock files. Would you like to DELETE them?", vbYesNo, "None Existent Stock Details!")
- If Reply = vbYes Then
- db.Execute "DELETE * FROM preordlin WHERE IsNull(StkID) And OrderNo = [Forms]![frmCustomerOrderForm]![sfrmSOHeader]![OrderNo]"
- Else
- Exit Sub
- End If
- Else
- rst!Price = DLookup("[SalePrice1]", "primas", "[StkID] =" & rst!StkID)
- rst!Cost = DLookup("[CostPrice1]", "primas", "[StkID] =" & rst!StkID)
- rst!ItemNo = rst!ItemNo + SeqItemNo
- rst.update
- SeqItemNo = SeqItemNo + 1
- End If
- rst.MoveNext
- Loop Until rst.EOF
- rst.Close
- Me.Requery
- Set rst = Nothing
- cmdCheckStock.Enabled = False
- cmdUpdateInformation.Enabled = True
- cmdAssignDetails.Enabled = False
- cmdcalcgrainmeasures.Enabled = False
- cmdImportintoOrderline.Enabled = False
- DoCmd.SetWarnings True
Could anyone tell me why this record will not delete? At present the code functions without errors and just moves on to the next record, but doesn't delete any in the process.