从子窗体中添加新的主记录 [英] Add new Main record from within subform

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

问题描述

你好,


我有一个表格"frm_Main"使用链接的子表单"sfrm_Claims"。 子表单通过tblMainID链接到主表单。 每个MainID可以有很多声明。


我希望能够在声明子表单中有一个控制按钮,这样在数据输入期间,在输入最后一个声明数据并且按钮具有焦点之后,用户可以点击开始添加新的主记录。


我已经尝试了几位代码,但都失败了。 复述,错误通常是"访问不能转到指定的控件"


这里是我到目前为止尝试过的事情


Public Function NewAppeal ()¥
On Error GoTo Err_NewAppeal

    'Form_frm_Main.LastName.SetFocus

    'DoCmd.GoToControl Forms!frm_Main!LastName

    'DoCmd.GoToRecord acDataForm," frm_Main",acNewRec

    'DoCmd.GoToRecord ,, acNewRec

Exit_NewAppeal:

   退出功能



Err_NewAppeal:

    MsgBox Err.Description

   恢复Exit_NewAppeal

   

结束功能


感谢您的帮助。

解决方案

您好,


我测试了它, DoCmd.GoToRecord acDataForm,"frm_Main",acNewRec 有效。


Nadia


Hello,

I have a form "frm_Main" with a linked subform "sfrm_Claims".  The subform is linked to the main form via the tblMainID.  Each MainID can have many Claims.

I want to be able to have a control button in the claims subform such that during data entry, after the last Claim data is entered and the button has focus, the user can click to start adding a new Main record.

I have tried several bits of code, and they all fail.  Paraphrasing, the error is usually "Access cannot go to the specified control"

here are the things I have tried so far

Public Function NewAppeal()
On Error GoTo Err_NewAppeal
    'Form_frm_Main.LastName.SetFocus
    'DoCmd.GoToControl Forms!frm_Main!LastName
    'DoCmd.GoToRecord acDataForm, "frm_Main", acNewRec
    'DoCmd.GoToRecord , , acNewRec
Exit_NewAppeal:
    Exit Function

Err_NewAppeal:
    MsgBox Err.Description
    Resume Exit_NewAppeal
   
End Function

Thanks for the help.

解决方案

Hello,

I tested it, and DoCmd.GoToRecord acDataForm, "frm_Main", acNewRec works.

Nadia


这篇关于从子窗体中添加新的主记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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