跨过程访问记录集 [英] Accessing Recordsets across procedures

查看:64
本文介绍了跨过程访问记录集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家,


我有一份未绑定的表格,记录了投诉的详细信息。它还记录了投诉中受影响的产品。它们存储在名为ComplaintProducts的表中,该表具有以下字段:ComplaintProductsIndex(Autonumber),ComplaintIndex& ProductName。


产品列表非常冗长,因此我设置了一个单独的表单,当双击Complaints表单上的Products Affected列表框时,会打开一个单独的表单,其中包含一个级联列表框选择产品的方法。双击产品列表框中的产品时,会将其添加到ComplaintProducts表中。双击此表单中的受影响的产品列表框将其从表中删除。这一切都是通过记录集完成的。


我希望能够在必要时编辑现有记录,并且该系统提供了这一点。我还希望用户能够在出现错误时取消此编辑程序,因此在此表单上我有一个取消按钮。我希望取消按钮忽略表格打开后对表格所做的任何更改然后将其关闭。


为了做到这一点,我已在表格上设置打开一个名为rstProductsExisting的记录集来捕获已经存在的产品。

然后在取消按钮事件中,我放置了代码,删除了适用于相关投诉的所有记录,然后添加了来自rstProducts的记录返回。


这是我的代码:

Hi Experts,

I have a unbound form which records details of complaints. It also records what products are affected in the complaint. These are stored in a table named ComplaintProducts that has the fields: ComplaintProductsIndex (Autonumber), ComplaintIndex & ProductName.

The product list is quite lengthy, so I have set up a separate form which opens when the Products Affected list box on the Complaints form is double clicked, containing a cascading list box method to choose the Product. When the product in the Products list box is double clicked, it is added to ComplaintProducts table. Double clicking on the Products Affected list box in this form deletes it from the table. This is all done through recordsets.

I want the ability to edit an existing record if necessary and this system provides that. I also want the user to be able to cancel this edit procedure if a mistake has been made, so on this form I have a cancel button. I would like the cancel button to disregard any changes made to the table while the form has been open and then close it.

In order to do this, I have set up on the Form Open procedure a recordset called rstProductsExisting to capture the products if any that are already there.
Then on the Cancel Button event I have placed code that deletes all the records that apply to the relevant complaint and then adds the records from rstProductsExisting back in.

Here is the code I have:

展开 | 选择 | 换行 | 行N umbers

推荐答案


嗨专家,


我有一个未绑定的表格,记录投诉的细节。它还记录了投诉中受影响的产品。它们存储在名为ComplaintProducts的表中,该表具有以下字段:ComplaintProductsIndex(Autonumber),ComplaintIndex& ProductName。


产品列表非常冗长,因此我设置了一个单独的表单,当双击Complaints表单上的Products Affected列表框时,会打开一个单独的表单,其中包含一个级联列表框选择产品的方法。双击产品列表框中的产品时,会将其添加到ComplaintProducts表中。双击此表单中的受影响的产品列表框将其从表中删除。这一切都是通过记录集完成的。


我希望能够在必要时编辑现有记录,并且该系统提供了这一点。我还希望用户能够在出现错误时取消此编辑程序,因此在此表单上我有一个取消按钮。我希望取消按钮忽略表格打开后对表格所做的任何更改然后将其关闭。


为了做到这一点,我已在表格上设置打开一个名为rstProductsExisting的记录集来捕获已经存在的产品。

然后在取消按钮事件中,我放置了代码,删除了适用于相关投诉的所有记录,然后添加了来自rstProducts的记录返回。


这是我的代码:

Hi Experts,

I have a unbound form which records details of complaints. It also records what products are affected in the complaint. These are stored in a table named ComplaintProducts that has the fields: ComplaintProductsIndex (Autonumber), ComplaintIndex & ProductName.

The product list is quite lengthy, so I have set up a separate form which opens when the Products Affected list box on the Complaints form is double clicked, containing a cascading list box method to choose the Product. When the product in the Products list box is double clicked, it is added to ComplaintProducts table. Double clicking on the Products Affected list box in this form deletes it from the table. This is all done through recordsets.

I want the ability to edit an existing record if necessary and this system provides that. I also want the user to be able to cancel this edit procedure if a mistake has been made, so on this form I have a cancel button. I would like the cancel button to disregard any changes made to the table while the form has been open and then close it.

In order to do this, I have set up on the Form Open procedure a recordset called rstProductsExisting to capture the products if any that are already there.
Then on the Cancel Button event I have placed code that deletes all the records that apply to the relevant complaint and then adds the records from rstProductsExisting back in.

Here is the code I have:

展开 | 选择 | 换行 | 行N umbers


感谢您快速回复ADezii,


如果我理解正确,您要说的是放置其中任何一个:
Thanks for the speedy reply ADezii,

If I understand you correctly, you are saying to place either of these:
展开 | 选择 | Wrap | 行号


您好ADezii,


我已将表单打开事件更改为表单加载事件和错误91不再显示。但是,当点击取消按钮时,我收到另一个错误:


3167:记录被删除


出现在第12行:

Hi ADezii,

I have changed the Form Open Event to a Form Load Event and Error 91 no longer shows. However, when clicking on the Cancel button I get another error:

3167: record is deleted

occuring at line 12:

展开 | 选择 | Wrap | 行号


这篇关于跨过程访问记录集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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