Slight change to code needed

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

Bob Vance asked:

I dont want the box to come up asking if I want to delete record, just want
it to be deleted after clicking it, Thanks Bob

Private Sub cmdDeleteDailyRow2_Click()

If MsgBox("Do You Want To Delete Daily Record?", vbApplicationModal +
vbQuestion + vbYesNo, "Delete Record") = vbYes Then

tbStartDate2.value = ""
tbEndDate2.value = ""
tbTotalDays2.value = ""
cbDailyCharge2.value = ""
tbDailyChargeRate2.value = ""
tbDailyChargeAmount2.value = ""

SubCalculate

End If

End Sub

Thanks in advance.........Bob Vance
 
Hi Bob!
You might want to try this variation which will delete the current record
and move the form to the next record. There is no need to empty-out all the
textboxes:

Private Sub cmdDeleteDailyRow2_Click()

If MsgBox("Do You Want To Delete Daily Record?", vbApplicationModal +
vbQuestion + vbYesNo, "Delete Record") = vbYes Then

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

End If

End Sub

If you want to avoid the "You are about to delete ... " message, go to
Tools --> Options --> Edit/Find and un-check Action queries in the Confirm
box.

Good luck!

I have an Access tutorial that you might want to look at:
www.profsr.com/home3.html

Professor Mike
 
Mike and Bob,
If you want to avoid the "You are about to delete ... " message, go to
Tools --> Options --> Edit/Find and un-check Action queries in the Confirm
box.
I'd like to suggest that you use the SetWarnings Method instead. You can
turn it Off, run the code, , and then turn it back On.
DoCmd.SetWarning False
'Run your code
DoCmd.SetWarnings True

During subsequent development of any Action Queries (MakeTable, Deletes,
Appends, etc...), not having any cancellable warning could lead to
inadvertent table damage.
Leave the Default Warning On, work out your Action Query code until it
works properly every time, and then turn the Warnings Off/On when you run
that code.

hth
Al Camp
 
Back
Top