形式与子表单重新查询问题 - ADO相关? [英] Form & Subform Requery Problem - ADO Related?

查看:73
本文介绍了形式与子表单重新查询问题 - ADO相关?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Access 2003.(我在我的绝大部分代码中也使用了ADO。我最近阅读了一篇帖子,表明ADO不是最初被破解的。在我的脑海中我很想知道这是否会导致我的问题,但我不想通过工作转换为DAO,除非我知道这真的符合我的最佳利益。)


我我有问题得到一个requery一致地出现在几种形式。我已经阅读了关于这个主题的各种帖子,但我不会开始理解为什么我不能这样做。我有以下设置:


表格A ​​= CourseInfoForm

表格B = OutcomeQuestionsForm

子表格C =结果问题表格

子表格C控制名称= sbfOutcomeQuestionsSubform

表格B&子表单C由一个名为ClassID的字段链接。


表单A包含一系列课程。您可以选择课程并单击按钮转到表单B.表单B包含所选课程的详细信息,以及与子表单C中的课程相关的问题。


在表格B上,用户可以单击按钮运行查询,将问题从另一个课程复制到当前课程中。这些问题将插入到Subform C查询的表中。在成功插入之后,我尝试了几种方法来重新查询或重新显示Subform C上的数据。在极少数情况下,新插入的行将出现在子表单C中,但通常我必须手动关闭表单B和子表单C并重新打开它们以查看更改。


以下是我的一些尝试:

1. Me.sbfOutcomeQuestionsSubform.Form.Requery?子表单C

2 。Me.sbfOutcomeQuestionsSubform.Form.Recalc?子表格C

3. Me.Requery?表格B?希望它重新查询子表单C

4. Me.OutcomeQuestionsForm.Requery?表单B?希望它重新查询子表单C

5.调用Me.sbfOutcomeQuestionsSubform.Form.Form_Load?试图强制加载子表单C重新加载。

6.?我甚至试图自动关闭并重新打开表格B&子表单C

DoCmd.Close acForm,OutcomeQuestionsForm

DoCmd.OpenFormOutcomeQuestionsForm


我已包括来自按钮的代码点击,以防它可能暴露问题。

I am using Access 2003. (I am also using ADO in the vast majority of my code. I recently read a post that indicated that ADO is not all that is was initially cracked up to be. In the back of my mind I am wonder if this is causing my problem, but I don?t want to go through the work to convert to DAO unless I know it is truly in my best interest.)

I am having problems getting a requery to show up consistently on a couple of forms. I have read all kinds of post on this subject, but I don?t begin to understand why I can?t get this to work. I have the following setup:

Form A = CourseInfoForm
Form B = OutcomeQuestionsForm
Subform C = OutcomeQuestionsSubform
Subform C Control Name = sbfOutcomeQuestionsSubform
Form B & Subform C are linked by a field called ClassID.

Form A contains a list of courses. You can select a course and click a button to go to Form B. Form B contains detail information for the selected course, along with Questions associated with the course that reside on Subform C.

On Form B the user can click a button to run a query to copy questions from another course into the current course. These questions are inserted into a table that Subform C queries against. After a successful insert I have tried several approaches to requery or redisplay the data on Subform C. On rare occasions the newly insert rows will appear in Subform C, but usually I have to mannually close Form B and Subform C and reopen them to see the changes.

Here are some of my attempts:
1. Me.sbfOutcomeQuestionsSubform.Form.Requery ?Subform C
2. Me.sbfOutcomeQuestionsSubform.Form.Recalc ?Subform C
3. Me.Requery ?Form B ? hoping it requery Subform C
4. Me.OutcomeQuestionsForm.Requery ?Form B ? hoping it requery Subform C
5. Call Me.sbfOutcomeQuestionsSubform.Form.Form_Load ?attempting to force a load subform C to reload.
6. ? I have even tried to automatically close and reopen Form B & Subform C
DoCmd.Close acForm, "OutcomeQuestionsForm"
DoCmd.OpenForm "OutcomeQuestionsForm"

I have included the code from the button click in case it might expose the problem.

展开 | 选择 | Wrap | 行号

推荐答案

1。检查子窗体对象的名称,因为它不总是与子窗体名称相同。在主窗体设计中,单击子窗体周围的框架并打开属性。检查其他选项卡下的名称属性。这是子表单对象的名称。


2.试试这段代码...
1. Check the name of the subform object as it is not always the same as the subform name. In the main form design click on the frame around the subform and open the properties. Check the name property under the Other tab. This is the name of the subform object.

2. Try this code ...
展开 | 选择 | 换行 | 行号


关于DAO与ADO。看一下之前关于这个主题的一些讨论。

TheScripts Tip第6周(DAO或ADO - 为什么不是两者?)

从DAO更改为MS ActiveX ADO
Regarding DAO vs. ADO. Have a look at some of the previous discussions on the subject.

TheScripts Tip of the Week #6 (DAO or ADO - Why Not Both?)

Changing from DAO to MS ActiveX ADO


Mary,

感谢您的帮助。我实现了您建议的Requery更改。我运行的第一个测试工作,但我运行requery的每个后续测试都没有显示,直到我手动关闭并重新打开窗口。我不明白。


你认为这与ADO有关吗? ......或者你认为这是别的吗?我很想听听你的想法。


此致,

Mark
Mary,

Thank you for your help. I implemented the Requery changes that you suggested. The first test that I ran worked, but every subsequent test I ran the requery did not show up until I manually closed and reopened the window. I don''t get it.

Do you think this is related to ADO? ...Or do you think it is something else? I am curious to hear your thought.

Sincerely,
Mark


这篇关于形式与子表单重新查询问题 - ADO相关?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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