Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to delete .addnew code if user unchecks field? 1

Status
Not open for further replies.

ffleitas

Technical User
Mar 15, 2001
85
US
Hello programmers,

I have a subform with the option to check off a yes/no field that when a user checks off the yes/no to equal yes it performs this operation:

Set db = CurrentDb
Set rs = db.OpenRecordset("tblCommissionsPaidSub", dbOpenDynaset)

If Me!Cleared = True Then

With rs

.AddNew
.Fields("DateofCommResidual") = Me!PaymentsDate
.Fields("RepresentativeID") = Forms!frmMembersEdit!RepresentativeID
.Fields("MemberID") = Me!MemberID
.Fields("ResidualPercent") = DLookup("Percentage", "tblPercentages", StrFilter3)
.Fields("ResidualAmount") = ((Forms!frmMembersEdit!MemberAmount * DLookup("Percentage", "tblPercentages", StrFilter3)) / 100)
.Update

End With

Set rs = Nothing
Set db = Nothing

Else


End If

If Me!Cleared = True Then

Me!ResidualTransferred = 1
Else

Me!ResidualTransferred = 0

End If

DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

My question is how do I delete this .addnew if the user makes a mistake and really wanted not to check off the field yes/no to no?
 
Thank you for responding. Unfortunately, the record that was transferred remains in the table. Is there another way of going about it?
 
Sure,

Use the same code (nearly) as above do an rs.movelast & rs.delete
 
Hello Rolliee,

Can you give me an short example of how you would write this code? I tried different ways but I want to make sure I am writing in the correct protocol.



Thanks,
Felix
 
private sub command0_click()
dim rs as dao.recordset
set rs = me.recordset
rs.movelast
rs.delete
rs.close
set rs = nothing
me.requery
docmd.gotorecord,,acLast
exit sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top