A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

delete record on a different form



 
 
Thread Tools Display Modes
  #1  
Old January 16th, 2010, 02:02 PM posted to microsoft.public.access.forms
vircalendar via AccessMonster.com
external usenet poster
 
Posts: 31
Default 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  
Old January 16th, 2010, 02:06 PM posted to microsoft.public.access.forms
vircalendar via AccessMonster.com
external usenet poster
 
Posts: 31
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:54 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.