hi,
whenever i key in some data into a form i will transfer the data into a table.
whenever i want to change some data in the form i will delete all the records in the table and re-add all the data from form into the table.
the abv method works. however, i find that it is not effiencent because it every time delete all the records and re-add in records.
how shall i code the program to make it only edit/delete the specific records only instead bulk delete and bulk add?
refer to (program.zip)
whenever i key in some data into a form i will transfer the data into a table.
whenever i want to change some data in the form i will delete all the records in the table and re-add all the data from form into the table.
the abv method works. however, i find that it is not effiencent because it every time delete all the records and re-add in records.
how shall i code the program to make it only edit/delete the specific records only instead bulk delete and bulk add?
refer to (program.zip)
Code:
Private Sub cmdSaveFltQpi_Click()
Dim Db As DAO.Database
Dim rs As DAO.Recordset
Dim sql As String
Dim f As Form
Dim i As Integer
Dim k As String
Set f = Forms!frmFltQpi
Set Db = CurrentDb()
Call DeleteRecords 'delete all the previous records
sql = "SELECT * FROM [tblFltQpiMonthly] Where tblFltYear = " & f.cboFltQpiYear
For i = 1 To 12 'transfer the data from form to table
Set rs = Db.OpenRecordset(sql)
If rs.RecordCount >= 0 Then
If IsNull(f("txtTotalJobs" & i) Or f("txtTotalRecurring" & i) Or f("txtTotalAirWC" & i) Or f("txtTotalAF" & i)) = False Then
rs.AddNew
rs![tblFltYear] = f.cboFltQpiYear
rs![tblFltMonth] = i
rs![tblFltTotalJobs] = f("txtTotalJobs" & i)
rs![tblFltTotalRecurring] = f("txtTotalRecurring" & i)
rs![tblFltTotalAirtestWC] = f("txtTotalAirWC" & i)
rs![tblFltTotalAirtestFailure] = f("txtTotalAF" & i)
rs.Update
End If
End If
Next i
Db.Close
End Sub
Private Sub DeleteRecords()
Dim sql As String
sql = "DELETE * FROM [tblFltQpiMonthly] Where tblFltYear = " & Me.cboFltQpiYear
DoCmd.SetWarnings False
DoCmd.RunSQL sql
End Sub