代码之家  ›  专栏  ›  技术社区  ›  blu

将2007设置字段访问到对话框中的选择

  •  2
  • blu  · 技术社区  · 16 年前

    我想将字段设置为从对话框中的网格中选择的值。我正在使用Access 2007。

    在WinForms中,我会:

    • 创建子窗体
      • 为所选项目添加属性
    • 以父形式
      • 添加一个按钮以打开表单
      • 更新对象
      • 持之以恒
    • 关于父编辑
      • 在子网格中设置选定值

    在Access 2007表单中是否可以这样做?我有一个包含子记录的多项目表单。我可以选择一个并将其返回给家长吗?另一方面,我可以在编辑时默认选中的项目吗?

    1 回复  |  直到 16 年前
        1
  •  1
  •   JohnFx    16 年前

    这里有一个模式,假设子窗体是模态的。

    以你父母的形式

    Private Sub cmdOpenChild_Click()
        DoCmd.OpenForm "ChildDialog", acNormal, , , , acDialog, "Info for child"
    
        'This line will block further code execution until child form is hidden or closed.  
        MsgBox Forms.Item("ChildDialog").Controls.Item("SomePropertyOrControl").Value
    
        DoCmd.Close acForm, "ChildDialog"
    end sub
    

    以儿童形式 有一个关闭按钮,实际上只隐藏窗体。

    Private Sub cmdClose_Click()
        'hide the form instead of closing it to return control to caller.
        Me.Visible = False
    End sub
    
    推荐文章