last record is deleted

  • Thread starter corics15 via AccessMonster.com
  • Start date
C

corics15 via AccessMonster.com

hello again! i have this piece of code which when executed deletes the last
record. i can't seem to figure it out as to why this is happening.

here's the table BEFORE execution of the below code.

Period Due Date Payment Due Balance
1 6/15/2008 1,026.67 11,293.33
2 6/30/2008 1,026.67 10,266.66
3 7/15/2008 1,026.67 9,239.99
4 7/31/2008 1,026.67 8,213.32
5 8/15/2008 1,026.67 7,186.65
6 8/31/2008 1,026.67 6,159.98
7 9/15/2008 1,026.67 5,133.31
8 9/30/2008 1,026.67 4,106.64
9 10/15/2008 1,026.67 3,079.97
10 10/31/2008 1,026.67 2,053.30
11 11/15/2008 1,026.67 1,026.63
12 11/30/2008 1,026.67 0.00

here's the table AFTER execution of the below code.

Period Due Date Payment Due Balance
1 6/15/2008 1,026.67 11,293.33
2 6/30/2008 1,026.67 10,266.66
3 7/15/2008 1,026.67 9,239.99
4 7/31/2008 1,026.67 8,213.32
5 8/15/2008 1,026.67 7,186.65
6 8/31/2008 1,026.67 6,159.98
7 9/15/2008 1,026.67 5,133.31
8 9/30/2008 1,026.67 4,106.64
9 10/15/2008 1,026.67 3,079.97
10 10/31/2008 1,026.67 2,053.30
11 11/15/2008 1,026.67 1,026.63

this code uses the .EDIT method, assuming i want to change the value of the
loaned amount, data should also change, but i have noticed that the last
record is being deleted. any help would be greatly appreciated.

If editFlag = True Then
rst.MoveLast '
populate recordset
rst.MoveFirst '
populate recordset
rst.FindFirst (memberID)
With rst
For I = start_date To end_date
If Day(I) = 15 Or Day(DateAdd("d", 1, I)) = 1 Then ' 15th or
last day of month
counter = counter + 1 ' let us
increment our counter!
.Edit ' edit or
update member records
![due_date] = I
![period] = counter
![payment_due] = Round(Form_frmMain.txtSemiMonthlyPmt, 2)
If counter = 1 Then
![balance] = Form_frmMain.txtTotal - ![payment_due]
Else
![balance] = Form_frmMain.txtTotal - (![payment_due] *
counter)
End If
![MemID] = Form_frmMain.txtMNo
.Update
.MoveNext
If .EOF Then .MoveLast
End If
Next I
End With
Else
 
R

Robert Morley

Are you sure it's being deleted and not filtered out? It looks like you're
searching for a specific record and editing it. I'm wondering if one of
your edits changes a value to something outside the search criteria (if any)
for your recordset.


Rob
hello again! i have this piece of code which when executed deletes the last
record. i can't seem to figure it out as to why this is happening.

here's the table BEFORE execution of the below code.

Period Due Date Payment Due Balance
1 6/15/2008 1,026.67 11,293.33
2 6/30/2008 1,026.67 10,266.66
3 7/15/2008 1,026.67 9,239.99
4 7/31/2008 1,026.67 8,213.32
5 8/15/2008 1,026.67 7,186.65
6 8/31/2008 1,026.67 6,159.98
7 9/15/2008 1,026.67 5,133.31
8 9/30/2008 1,026.67 4,106.64
9 10/15/2008 1,026.67 3,079.97
10 10/31/2008 1,026.67 2,053.30
11 11/15/2008 1,026.67 1,026.63
12 11/30/2008 1,026.67 0.00

here's the table AFTER execution of the below code.

Period Due Date Payment Due Balance
1 6/15/2008 1,026.67 11,293.33
2 6/30/2008 1,026.67 10,266.66
3 7/15/2008 1,026.67 9,239.99
4 7/31/2008 1,026.67 8,213.32
5 8/15/2008 1,026.67 7,186.65
6 8/31/2008 1,026.67 6,159.98
7 9/15/2008 1,026.67 5,133.31
8 9/30/2008 1,026.67 4,106.64
9 10/15/2008 1,026.67 3,079.97
10 10/31/2008 1,026.67 2,053.30
11 11/15/2008 1,026.67 1,026.63

this code uses the .EDIT method, assuming i want to change the value of the
loaned amount, data should also change, but i have noticed that the last
record is being deleted. any help would be greatly appreciated.

If editFlag = True Then
rst.MoveLast '
populate recordset
rst.MoveFirst '
populate recordset
rst.FindFirst (memberID)
With rst
For I = start_date To end_date
If Day(I) = 15 Or Day(DateAdd("d", 1, I)) = 1 Then ' 15th or
last day of month
counter = counter + 1 ' let us
increment our counter!
.Edit ' edit or
update member records
![due_date] = I
![period] = counter
![payment_due] = Round(Form_frmMain.txtSemiMonthlyPmt, 2)
If counter = 1 Then
![balance] = Form_frmMain.txtTotal - ![payment_due]
Else
![balance] = Form_frmMain.txtTotal - (![payment_due] *
counter)
End If
![MemID] = Form_frmMain.txtMNo
.Update
.MoveNext
If .EOF Then .MoveLast
End If
Next I
End With
Else
 
C

corics15 via AccessMonster.com

Yes, I am pretty sure that it's being deleted and not filtered out. I used
the findfirst method to find the first instance of a certain record and edit
the next one and the next one until the counter reaches a certain number,
let's say 12. I really don't know why this is happening. Any help is really
appreciated.

Robert said:
Are you sure it's being deleted and not filtered out? It looks like you're
searching for a specific record and editing it. I'm wondering if one of
your edits changes a value to something outside the search criteria (if any)
for your recordset.

Rob
hello again! i have this piece of code which when executed deletes the last
record. i can't seem to figure it out as to why this is happening.
[quoted text clipped - 65 lines]
End With
Else
 
R

Robert Morley

Well, there's nothing in the code you've shown us that could possibly delete
the record, therefore it must be coming from somewhere outside this code.

If the problem only happens when you're running this particular code, then
either there's something missing somewhere (the previously-mentioned
filtering, a Delete somewhere that you haven't clued in to, etc.) OR if this
is taking place on something like SQL Server, then perhaps some code is
running server-side that's deleting records under certain conditions.


Rob
Yes, I am pretty sure that it's being deleted and not filtered out. I used
the findfirst method to find the first instance of a certain record and edit
the next one and the next one until the counter reaches a certain number,
let's say 12. I really don't know why this is happening. Any help is really
appreciated.

Robert said:
Are you sure it's being deleted and not filtered out? It looks like you're
searching for a specific record and editing it. I'm wondering if one of
your edits changes a value to something outside the search criteria (if any)
for your recordset.

Rob
hello again! i have this piece of code which when executed deletes the last
record. i can't seem to figure it out as to why this is happening.
[quoted text clipped - 65 lines]
End With
Else
 
C

corics15 via AccessMonster.com

Thanks Rob. I have managed to get a work around solution in my problem.
Thanks for your response!

Robert said:
Well, there's nothing in the code you've shown us that could possibly delete
the record, therefore it must be coming from somewhere outside this code.

If the problem only happens when you're running this particular code, then
either there's something missing somewhere (the previously-mentioned
filtering, a Delete somewhere that you haven't clued in to, etc.) OR if this
is taking place on something like SQL Server, then perhaps some code is
running server-side that's deleting records under certain conditions.

Rob
Yes, I am pretty sure that it's being deleted and not filtered out. I used
the findfirst method to find the first instance of a certain record and edit
[quoted text clipped - 14 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top