使用主窗体RecordSet的子窗体 [英] Child Forms Using Main Form RecordSet

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

问题描述

我有一个带有几个绑定文本框的表单。这些通常由用户更新。此表单的RecordSource表中当前有8个字段未显示在此表单上,但偶尔需要由用户更改。为此,我创建了一个高级 commandbutton,用于打开包含控件的子窗体以显示其余字段。


我尝试使用recordsetclone将子表单放在与主表单相同的记录和记录集上,但是当子表单关闭时,克隆会更新。然后主窗体在尝试更新同一记录时会出现写冲突。


我在另一个问题上找到了一个示例代码,我稍微修改了一下并上传到这里。 FishVal原创我认为。


儿童表格1似乎做我需要的。表单2和表3传递对控件的引用,而不是基础数据。由于我目前有8个字段,这些似乎不合适。


1)打开表单=" frmmain",然后移动到记录2.将Text2更改为其他内容,即R 2aaa ;。

移动到记录3.按UnDo按钮,记录返回到记录2并撤消。但是导航到新记录应该保存更改。为什么在显示记录3时没有记录2保存?


2)打开表格=frmmain,然后移动到记录2.单击子表单1按钮。改为别的东西,即记录2ccc。按提交。按UnDo按钮。为什么命令撤销现在不可用。 frmChild1的记录集与frmMain相同,并且记录没有被移动到另一条记录,为什么Undo不可用?


3)程序Private Sub txb_BeforeUpdate ..."在取消的情况下,在child1的代码中为此文本框保存.OldValue。按钮被按下。这不应该是必要的,因为.OldValue是记录中的值,并且应该保留到记录更新之前。文本框更新后,文本将丢失。如果我注释掉这个语句,并在Private Sub btnCancel_Click()中放置一个断点。 Me.txb.OldValue是更新的文本框值,而不是记录集原始值。为什么?


4)如果选择新记录然后使用child1,当我按下提交时我收到消息更新或取消更新,没有AddNew或编辑。在frmMain和frmChild1上都是AllowAdditions = Yes,那么为什么会这个消息呢?

OldBirdman

解决方案

现在附件.. 。


我会把它弄好的!

OldBirdman





附加文件 < tr>
子窗体相同记录集。 zip (23.1 KB,121 views)


如果没有检查你的样品,我很惊讶或者你考虑过使用标签控件?

这个看起来像您的附加[高级]按钮,但允许您在一个表单上包含所有字段。您甚至可以通过更改选项卡控件的属性将Tab更改为按钮...


想法?


Nic; o)

I have a form with several bound textboxes. These are routinely updated by User. The table in RecordSource for this form currently has 8 fields not shown on this form, but which occasionally need to be changed by User. For this I have created an "Advanced" commandbutton, which opens a child form with controls to display the remaining fields.

I tried using recordsetclone to put the child form on the same record and recordset as the main form, but when the child form is closed, the clone is updated. Then the main form gets a write conflict when it tries to update the same record.

I found a sample code on another question which I have modified slightly and uploaded here. Original by FishVal I think.

Child form 1 seems to do what I need. Forms 2 and 3 pass references to a control, not the underlying data. As I have currently 8 fields, these seem inappropriate.

1) Open form = "frmmain", and move to record 2. Change Text2 to something else, i.e. "R 2aaa".
Move to record 3. Press the UnDo button, and the record is returned to record 2 and that is undone. But navagating to a new record should save the changes. Why wasn''t record 2 saved when record 3 displayed?

2) Open form = "frmmain", and move to record 2. Click the Child Form 1 button. Change to something else, i.e. "Record 2ccc". Press submit. Press the UnDo button. Why isn''t the command ''Undo'' available now. The recordset for frmChild1 is the same as for frmMain, and the record has not been moved to another record, so why is the Undo unavailable?

3) The procedure "Private Sub txb_BeforeUpdate..." in the code for child1 saves .OldValue for this textbox in case the "Cancel" button is pushed. This should not be necessary, as .OldValue is the value in the record, and should remain until the record is updated. .Text would be lost after the textbox were updated. If I comment out this statement, and put a breakpoint in "Private Sub btnCancel_Click()". Me.txb.OldValue is the updated textbox value, not the recordset original value. Why?

4) If new record is selected and then child1 used, when I press "Submit" I get message "Update or CancelUpdate without AddNew or Edit." AllowAdditions = Yes on both frmMain and frmChild1, so why this message?

OldBirdman

解决方案

And now the Attachment...


I''ll get it right yet!
OldBirdman

Attached Files
Child Form Same Recordset.zip (23.1 KB, 121 views)


Without checking your sample, I do wonder or you considered to use the tab control ?
This "looks like" your additional [Advanced] button, but will allow you to have all fields on one form. You can even change the Tab into Buttons by changing the tab control''s properties...

Idea ?

Nic;o)


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

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