从主窗体中撤消子窗体 [英] Undo subform from main form

查看:89
本文介绍了从主窗体中撤消子窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对子表格做的不多 - 实际上我故意避免使用它们 - 但是

....


我有一个选项卡控件,它将包含多个子表单,每个子表单绑定到一个

单独的表,每个表/子表单将与同一个人相关 - 但是

子表单数据不会与主表单''链接'。


我希望在所有

子表单上都有一个取消按钮用于所有撤消操作,所以个别子表单的Public Sub,Form_Cancel将被称为

,具体取决于要取消的子表单:


选择Case Me.tabSupervision.Value''main表格的标签控制

案例程序

Me.ProgramSub.Form.Form_Cancel

案例DRUG_TESTS

我.DrugSub.Form.Form_Cancel


等......


好​​了..现在,因为当取消按钮<时,子窗体失去焦点在主窗体上选择了
,我遇到麻烦了解除数据

的变化。在子窗体的Form_Cancel子中,Me.Undo不起作用。我认为

设置值= OldValue会起作用,但是......好吧,它不会。


那么会是什么?

Darryl Kerkeslager

I don''t do much with subforms - in fact I''ve deliberately avoided them - but
....

I have a tab control that will contain several subforms, each bound to a
separate table, and each table/subform will relate to the same person - but
the subform data will not be ''linked'' to the main form.

I want to have one Cancel button for all the undo operations on all the
subforms, so the individul subform''s Public Sub, Form_Cancel will be called
depending on the subform to be cancelled:

Select Case Me.tabSupervision.Value '' main form''s tab control
Case PROGRAMS
Me.ProgramSub.Form.Form_Cancel
Case DRUG_TESTS
Me.DrugSub.Form.Form_Cancel

etc...

Okay .. now, since the subform loses focus when the Cancel button is
selected on the main form, I''m having trouble easily undoing the data
changes. In the subform''s Form_Cancel sub, Me.Undo doesn''t work. I thought
setting the value = OldValue would work, but ... well, it doesn''t.

So what will?
Darryl Kerkeslager

推荐答案

撤消仅在当前记录尚未保存时有效。当您从子窗体转到另一个子窗体或主窗体时,$

子窗体上的记录会被保存,因此您无法再撤消它。相同的

原则适用于旧值。一旦记录被保存,所有控件的旧值

将丢失,并且旧值将丢失。成为保存

的价值或屏幕上显示的当前值。


要回答您的问题,您所能做的就是删除显示的记录

屏幕:

选择案例Me.tabSupervision.Value''主窗体'的标签控件

案例程序

我!ProgramSub.SetFocus

我!ProgramSub!NameOfSomeFieldOnProgramSub

DoCmd.RunCommand acDeleteRecord

案例DRUG_TESTS

Me.DrugSub.SetFocus

我!DrugSub!NameOfSomeFieldOnDrugSub

DoCmd.RunCommand acDeleteRecord


-

PC数据表

您的资源以获取Access,Excel和Word应用程序的帮助
重新* *****@pcdatasheet.com
www.pcdatasheet.com


" Darryl Kerkeslager" <柯********* @ comcast.net>在消息中写道

news:f - ******************** @ comcast.com ...
Undo only works if the current record has not yet been saved. When you go
from a subform to another subform or to the main form, the record on that
subform gets saved and consequently you can no longer undo it. The same
principle applies to the old value. Once a record gets saved, the old value
of all the controls is lost and the "old value" becomes the value that got
saved or the current value shown on the screen.

To answer your question, all you can do is delete the record shown on the
screen:
Select Case Me.tabSupervision.Value '' main form''s tab control
Case PROGRAMS
Me!ProgramSub.SetFocus
Me!ProgramSub!NameOfSomeFieldOnProgramSub
DoCmd.RunCommand acDeleteRecord
Case DRUG_TESTS
Me.DrugSub.SetFocus
Me!DrugSub!NameOfSomeFieldOnDrugSub
DoCmd.RunCommand acDeleteRecord

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com


"Darryl Kerkeslager" <Ke*********@comcast.net> wrote in message
news:f-********************@comcast.com...
我没有做太多的子表格 - 事实上我故意避免它们 -
但是...

我有一个标签控件,它将包含几个子表单,每个子表单都绑定到一个单独的表,每个表/子表将与同一个人相关 -
但子表单数据不会与主表单链接。

我想要对所有
子表单上的所有撤消操作都有一个取消按钮,因此根据要取消的子表单,单个子表单的Public Sub,Form_Cancel将被调用


选择Case Me.tabSupervision.Value''主窗体'的标签控件
案例程序
Me.ProgramSub.Form.Form_Cancel
案例DRUG_TESTS
Me.DrugSub .Form.Form_Cancel

等...

好的..现在,因为子窗体失去了焦点在主表单上选择了取消按钮,我很难轻易撤消数据更改。在子窗体的Form_Cancel子中,Me.Undo不起作用。 I
以为设置值= OldValue会起作用,但是......好吧,它不会。

那会是什么?

Darryl Kerkeslager
I don''t do much with subforms - in fact I''ve deliberately avoided them - but ...

I have a tab control that will contain several subforms, each bound to a
separate table, and each table/subform will relate to the same person - but the subform data will not be ''linked'' to the main form.

I want to have one Cancel button for all the undo operations on all the
subforms, so the individul subform''s Public Sub, Form_Cancel will be called depending on the subform to be cancelled:

Select Case Me.tabSupervision.Value '' main form''s tab control
Case PROGRAMS
Me.ProgramSub.Form.Form_Cancel
Case DRUG_TESTS
Me.DrugSub.Form.Form_Cancel

etc...

Okay .. now, since the subform loses focus when the Cancel button is
selected on the main form, I''m having trouble easily undoing the data
changes. In the subform''s Form_Cancel sub, Me.Undo doesn''t work. I thought setting the value = OldValue would work, but ... well, it doesn''t.

So what will?
Darryl Kerkeslager



这个新闻组不会睡觉吗? ;)


我希望有一种更容易的方式让我失踪。我的FE在BE的克隆表中为当前人编辑了

记录,

只是当前人的记录。如果我删除当前记录,我会以某种方式恢复它 - 从存储的变量,从BE(uck!)重新加载,

文本文件或临时表。或者......也许如果,当记录被弄脏时,

我将当前记录复制到一个不可能的新记录中。 ID为0,只是

将ID存储在变量中,然后将记录0的ID号更改为

当前ID(如果需要在撤消时删除)。嗯..


谢谢,Steve。

Darryl Kerkeslager


" PC数据表" <无**** @ nospam.spam>写道:
Doesn''t this newsgroup ever sleep? ;)

I was hoping there was an easier way that I was missing. My FE stores
records for the current person being edited in cloned tables of the BE, with
just the current person''s records. If I delete the current record, I have
to restore it somehow - from stored variables, reloading from the BE (uck!),
text file, or a temp table. Or ... perhaps if, when the record is dirtied,
I copied the current record to a new record with "impossible" ID of 0, just
store the ID in a varaible, then change the ID number of record 0 to the
current ID if it needs to be deleted on Undo ... hmmm ..

Thanks, Steve.
Darryl Kerkeslager

"PC Datasheet" <no****@nospam.spam> wrote:
撤消仅在当前记录尚未保存时有效。从子窗体转到另一个子窗体或主窗体时,该
子窗体上的记录将被保存,因此您无法再撤消它。同样的原则适用于旧的价值。保存记录后,所有控件的旧
值将丢失,并且旧值将丢失。成为保存的值或屏幕上显示的当前值。

要回答您的问题,您所能做的就是删除
屏幕上显示的记录:<选择Case Me.tabSupervision.Value''主窗体'的标签控件
案例程序
我!ProgramSub.SetFocus
我!ProgramSub!NameOfSomeFieldOnProgramSub
DoCmd.RunCommand acDeleteRecord
案件DRUG_TESTS
Me.DrugSub.SetFocus
我!DrugSub!NameOfSomeFieldOnDrugSub
DoCmd.RunCommand acDeleteRecord

-
PC数据表
您的资源以获取Access,Excel和Word应用程序的帮助
re ****** @ pcdatasheet.com
www.pcdatasheet.com


Darryl Kerkeslager <柯********* @ comcast.net>在消息中写道
新闻:f - ******************** @ comcast.com ...
Undo only works if the current record has not yet been saved. When you go
from a subform to another subform or to the main form, the record on that
subform gets saved and consequently you can no longer undo it. The same
principle applies to the old value. Once a record gets saved, the old value of all the controls is lost and the "old value" becomes the value that got
saved or the current value shown on the screen.

To answer your question, all you can do is delete the record shown on the
screen:
Select Case Me.tabSupervision.Value '' main form''s tab control
Case PROGRAMS
Me!ProgramSub.SetFocus
Me!ProgramSub!NameOfSomeFieldOnProgramSub
DoCmd.RunCommand acDeleteRecord
Case DRUG_TESTS
Me.DrugSub.SetFocus
Me!DrugSub!NameOfSomeFieldOnDrugSub
DoCmd.RunCommand acDeleteRecord

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com


"Darryl Kerkeslager" <Ke*********@comcast.net> wrote in message
news:f-********************@comcast.com...
我不知道对子表单做了很多事 - 事实上我故意避免使用它们 -
I don''t do much with subforms - in fact I''ve deliberately avoided them -


...

我有一个制表符控件,将包含几个子表单,每个子表单绑定到一个单独的表,每个表/子表单将与同一个人相关 -
...

I have a tab control that will contain several subforms, each bound to a
separate table, and each table/subform will relate to the same person -


子表单数据不会与主表单链接。

我希望在所有
子表单上都有一个取消按钮用于所有撤消操作,因此个别子表单的Public Sub, Form_Cancel将被
the subform data will not be ''linked'' to the main form.

I want to have one Cancel button for all the undo operations on all the
subforms, so the individul subform''s Public Sub, Form_Cancel will be


称为

,具体取决于要取消的子表单:

选择Case Me.tabSupervision.Value''main form'的选项卡控件
案例程序
Me.ProgramSub.Form.Form_Cancel
案例DRUG_TESTS Me.DrugSub.Form.Form_Cancel

等...

好的..现在,因为当选择了取消按钮时子窗体失去焦点主要形式,我很难轻易撤消数据更改。在子窗体的Form_Cancel子中,Me.Undo不起作用。我
depending on the subform to be cancelled:

Select Case Me.tabSupervision.Value '' main form''s tab control
Case PROGRAMS
Me.ProgramSub.Form.Form_Cancel
Case DRUG_TESTS
Me.DrugSub.Form.Form_Cancel

etc...

Okay .. now, since the subform loses focus when the Cancel button is
selected on the main form, I''m having trouble easily undoing the data
changes. In the subform''s Form_Cancel sub, Me.Undo doesn''t work. I


想到

设置值= OldValue会起作用,但是......好吧,它没有。

那会是什么?

Darryl Kerkeslager
setting the value = OldValue would work, but ... well, it doesn''t.

So what will?
Darryl Kerkeslager




Darryl Kerkeslager写道:
Darryl Kerkeslager wrote:
这个新闻组不会睡觉吗? ;)


在这里,您拥有全球网络的绝佳优势! :-)

我希望有一种更容易让我失踪的方式。我的FE在BE的克隆表中存储当前正在编辑的人的记录,
只是当前人的记录。如果我删除当前记录,我会以某种方式恢复它 - 从存储的变量,从BE(uck!),
文本文件或临时表重新加载。或者......也许如果,当记录被弄脏时,我将当前记录复制到一个不可能的新记录中。 ID为0,只是将ID存储在变量中,然后将记录0的ID号更改为
当前ID,如果需要在撤消时删除...嗯...
Doesn''t this newsgroup ever sleep? ;)
Here you have a splendid advantage of world-wide netting! :-)
I was hoping there was an easier way that I was missing. My FE stores
records for the current person being edited in cloned tables of the BE, with
just the current person''s records. If I delete the current record, I have
to restore it somehow - from stored variables, reloading from the BE (uck!),
text file, or a temp table. Or ... perhaps if, when the record is dirtied,
I copied the current record to a new record with "impossible" ID of 0, just
store the ID in a varaible, then change the ID number of record 0 to the
current ID if it needs to be deleted on Undo ... hmmm ..




撤消并不简单!至少不是设计师。我一直试图对我的一个项目实施一种有限形式的撤销,但是每一种改变信息的方法都必须以一种方式注册到中央

撤消对象,否则它不会工作。


您可以考虑将您提供的编辑记录存储到缓冲区

首先。是的,如你所说,用不可能的ID复制。我认为那是最近的


-

Bas Cost Budde,荷兰
http://www.heuveltop.nl/BasCB/msac_index.html

我更喜欢人工邮件高于自动化,所以在我的地址中

用茶替换队列



Undo is not simple! At least not to the designer. I have been trying to
implement a limited form of Undo to one of my projects, but every method
that changes information must register its change in a way to a central
undo object, otherwise it won''t work.

You could consider storing the record you offer for edit to a buffer
first. Yes, as you say, copy with the impossible ID. I think that is
closest.
--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea


这篇关于从主窗体中撤消子窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆