Hi All...
I created a query to append and to delete data from my main table to the new history table. It's successful..
I have another headache point by which :
I have a FieldName: MyDate in my main table Date() which stores date of record entry. If MyDate < System Date which is Now() -30 ... i.e. if the data is stored for more than 30 days then it moves to history table.. by this time changes and editing can occur. After 30 days, it moves to history table where no one can do any changes.
The code is under CmdSave Button as follows :
' To Insert a record in a history table after one month of System Date...
If Me.Date < Now() - 30 Then
strSQL = "INSERT INTO tblHistory SELECT DISTINCTROW tblStaffData.*,FROM tblStaffData INNER JOIN tblFollowData ON [tblStaffData].[IdNo]=[tblFollowData].[IdNoMain] WHERE (idno = '" & IdNo & "');"
DoCmd.RunSQL strSQL
' To Delete a record from our main table ...
strSQL = "DELETE FROM tblStaffData WHERE (idno = '" & IdNo & "');"
DoCmd.RunSQL strSQL
MsgBox "Record Transfered to History"
The problem is that I have to view all records one by one and when press Save, it check for date and either move data or not which is not practical.
My aim is whenever I press save button, system should check all records and if MyDate is fulfilling the criteria it should follow the procedure etc..
Do I have to use Loop between all the records, and if Yes... How..
Help is highly appreciated.
Thanks
Haytham
I created a query to append and to delete data from my main table to the new history table. It's successful..
I have another headache point by which :
I have a FieldName: MyDate in my main table Date() which stores date of record entry. If MyDate < System Date which is Now() -30 ... i.e. if the data is stored for more than 30 days then it moves to history table.. by this time changes and editing can occur. After 30 days, it moves to history table where no one can do any changes.
The code is under CmdSave Button as follows :
' To Insert a record in a history table after one month of System Date...
If Me.Date < Now() - 30 Then
strSQL = "INSERT INTO tblHistory SELECT DISTINCTROW tblStaffData.*,FROM tblStaffData INNER JOIN tblFollowData ON [tblStaffData].[IdNo]=[tblFollowData].[IdNoMain] WHERE (idno = '" & IdNo & "');"
DoCmd.RunSQL strSQL
' To Delete a record from our main table ...
strSQL = "DELETE FROM tblStaffData WHERE (idno = '" & IdNo & "');"
DoCmd.RunSQL strSQL
MsgBox "Record Transfered to History"
The problem is that I have to view all records one by one and when press Save, it check for date and either move data or not which is not practical.
My aim is whenever I press save button, system should check all records and if MyDate is fulfilling the criteria it should follow the procedure etc..
Do I have to use Loop between all the records, and if Yes... How..
Help is highly appreciated.
Thanks
Haytham