If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
delete record on a different form
I have a form with a subform. There is a delete button on the main form that
runs the following delete code to delete a record on the subform: Private Sub Delete_button_Click() Dim msg, style, title, Response, MyString msg = "This action will delete the current record" style = vbYesNo + vbCritical + vbDefaultButton2 title = "Caution" Response = MsgBox(msg, style, title) If Response = vbYes Then Forms![fmain]![fsub].SetFocus Forms![fmain]![fsub]!control1.SetFocus DoCmd.SetWarnings False DoCmd.RunCommand acCmdDeleteRecord DoCmd.SetWarnings True Else End End If End Sub This works fine, but I want to put a timer on the message that ends the procedure if the user does not respond in a specific period of time. For workflow reasons, I also want to move the delete button to the subform. Now, when the user hits the delete button, he opens a separate form (with a timer) that shows the warning text and has an accept and a reject button. If he hits accept, the code is: Private Sub accept_button_Click() Forms![fmain]![fsub].SetFocus Forms![fmain]![fsub]!ctxt.SetFocus DoCmd.SetWarnings False DoCmd.RunCommand acCmdDeleteRecord DoCmd.SetWarnings True Else ' User chose No. End Sub It's the same code, but running from a different form, and it does nothing. The record is not deleted. I also tried making the original code (minus the msgbox) a public sub and changed the code on my second form to Private Sub accept_button_Click() Forms![fmain].delete_button End Sub but that also did nothing. What am I missing? -- Message posted via http://www.accessmonster.com |
#2
|
|||
|
|||
delete record on a different form
note: when I entered my demo code, I accidentally showed the control getting
focus as ctxt in one location and control1 in the other. In fact, these are the same in both versions of the code. vircalendar wrote: I have a form with a subform. There is a delete button on the main form that runs the following delete code to delete a record on the subform: Private Sub Delete_button_Click() Dim msg, style, title, Response, MyString msg = "This action will delete the current record" style = vbYesNo + vbCritical + vbDefaultButton2 title = "Caution" Response = MsgBox(msg, style, title) If Response = vbYes Then Forms![fmain]![fsub].SetFocus Forms![fmain]![fsub]!control1.SetFocus DoCmd.SetWarnings False DoCmd.RunCommand acCmdDeleteRecord DoCmd.SetWarnings True Else End End If End Sub This works fine, but I want to put a timer on the message that ends the procedure if the user does not respond in a specific period of time. For workflow reasons, I also want to move the delete button to the subform. Now, when the user hits the delete button, he opens a separate form (with a timer) that shows the warning text and has an accept and a reject button. If he hits accept, the code is: Private Sub accept_button_Click() Forms![fmain]![fsub].SetFocus Forms![fmain]![fsub]!ctxt.SetFocus DoCmd.SetWarnings False DoCmd.RunCommand acCmdDeleteRecord DoCmd.SetWarnings True Else ' User chose No. End Sub It's the same code, but running from a different form, and it does nothing. The record is not deleted. I also tried making the original code (minus the msgbox) a public sub and changed the code on my second form to Private Sub accept_button_Click() Forms![fmain].delete_button End Sub but that also did nothing. What am I missing? -- Message posted via http://www.accessmonster.com |
Thread Tools | |
Display Modes | |
|
|