尝试同步父表单和子表单,都使用相同的表,取消链接 [英] trying to sync parent form and subform, both use same table, unlinked

查看:136
本文介绍了尝试同步父表单和子表单,都使用相同的表,取消链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了一个普通的子表单并将其放在普通表单上。  问题是子表单上的记录选择是否发生错误。   子表单 未链接到父表单。 两种表单都使用相同的表格。 
唯一的代码是在"当前"字母上子表单的事件,目的是使它们保持同步。 

I've built a normal subform and placed it on a normal form.  The problem is record selection on the subform happens erradically.  The subform is NOT linked to the parent form.  Both forms use the same table.  The only code is on the "Current" event of the subform, with the purpose of keeping them in sync. 

Private Sub Form_Current()

  Dim frm As Form

  Dim As As Object

 

 设置frm = Me.Parent

 

 如果是frm.ID<> Me.ID然后是
   设置rst = frm.Recordset.Clone

   使用rst

      .FindFirst"ID =" &安培; Me.ID

     如果不是.NoMatch则为
        frm.Bookmark =。书签

     结束如果是
   结束与$
 结束如果

结束子

Private Sub Form_Current()
  Dim frm As Form
  Dim rst As Object
 
  Set frm = Me.Parent
 
  If frm.ID <> Me.ID Then
    Set rst = frm.Recordset.Clone
    With rst
      .FindFirst "ID = " & Me.ID
      If Not .NoMatch Then
        frm.Bookmark = .Bookmark
      End If
    End With
  End If
End Sub

首先,我可以点击子表单上的记录,一切顺利。 然后它开始恶性地行动。 当我点击一条记录时,突出显示首先会回到当事情开始根本不起作用时突出显示的记录,特别是
它突出显示该记录的ID字段。 只有在我第二次点击记录后才会突出显示正确的记录和字段。

At first, I can click records on the subform and all is well.  Then it begins acting erradically.  When I click a record, the highlight first moves back to the record that was highlighted when things began acting erradically, and specifically, it highlights the ID field of that record.  It is only after I click a record the second time that the correct record and field is highlighted.

我的理论是Access在某处资源不足,但我怎么知道呢? &NBSP;我已经从头开始完全重建父表单和子表单,结果相同。 在进行故障排除时,我添加了代码,以便子表单自行书签。 
结果是第一次点击时突出显示了正确的记录,但是需要第二次点击才能突出显示正确的字段而不是ID字段。 我迷糊了。

My theory is that Access is running out of resources somewhere, but how can I tell?  I've completely rebuilt the parent form and subform from scratch, with the same results.  While trouble-shooting, I added code so that the subform bookmarks itself.  The result is the correct record is highlighted on the first click, however a second click is necessary to highlight the correct field instead of the ID field.  I'm befuddled.

 

推荐答案

你想要完成什么?你试图满足的需要是什么?
What are you trying to accomplish? What is the need that you're trying to meet?


这篇关于尝试同步父表单和子表单,都使用相同的表,取消链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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