访问主窗体和子窗体中的重复记录 [英] Duplicate record in Access Main Form and Sub Form

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

问题描述

在我的Access程序中,我有一个主表单,其中包含配方常规信息和保留实际公式的子表单。主窗体名称是recipe,Record Source是名为TRecipeName的表。子表单名称为Recipe_Sub,Record Source是一个名为Q_Recipe的查询

表TRecipeName中的两个主键使每个记录唯一,recipeID(与文本字段txt_recipeID关联) 在主窗体中和RecipeVersion(与主窗体中的文本字段txtRecipeVer相关联)。两个字段都用于关联子表单。


创建一个按钮,用于复制与当前记录和新版本保持相同食谱ID的记录,并将当前记录中的所有信息转移到新版本。


我试图遵循Allen Browne为此功能开发的Vba代码(稍作修改)但遇到错误信息。由于我不熟悉RecordsetClone的概念和Vba中的SQL语句,我希望有人可以查看我的代码并帮助解决我的问题。


当我尝试使用代码时弹出错误信息:

运行时错误'2465'

系统找不到表达式中引用的字段'| 1'。


单击调试按钮,然后Access指向以下行(第43行):

In my Access program, I have a main form that holds recipe general information and a sub-form that keeps the actual formula. The main form name is “recipe” and Record Source is a table named “TRecipeName”. Sub-form name is Recipe_Sub and Record Source is a Query named “Q_Recipe”

Two primary keys in the table TRecipeName to make each record unique, recipeID (associate to the text field “txt_recipeID “ in the main form) and RecipeVersion (associated to the text field “txtRecipeVer” in the main form). Both fields are used to associate to the sub-form.

A button is created to duplicate a record that keeps same recipe ID as current record and new version with all information from current record carried over to the new version.

I tried to follow Vba codes that Allen Browne developed (with a few modifications) for this function but running into error message. Since I am not familiar with the concept of RecordsetClone and the SQL statement in Vba I am hoping someone can take a look of my code and help solve my issue.

When I tried following codes the error message pop up:
Run-time error ‘2465’
System can’t find the field ‘|1’ referred to in your expression.

When clicked debug button then Access pointed to the following line (line #43):

展开 | 选择 | 换行 | 行号

推荐答案

请做deb ug /先编译如下所述:

[*] >发布之前(VBA或SQL)代码


您将需要修复任何错误,然后重新运行调试/编译,直到它没有返回任何错误。

我。[Recipe_Sub]。是对子窗体的典型引用...你在主窗体上有一个名为Recipe_Sub的子窗体吗?或者这里有拼写错误?检查子表单的属性。
please do the debug/compile first as described here:
[*]> Before Posting (VBA or SQL) Code

You will need to fix any errors and then re-run the debug/compile until it returns no errors.

Me.[Recipe_Sub]. is a typical reference to a subform... do you have a subform on the mainform that is named "Recipe_Sub" or is there a typo here? Check the properties of the subform.


您好zmbd,


Recipe_Sub是一个实际的表单名称。我不知道如何修复代码所以我无法弄清楚如何调试....


谢谢,

Joe
Hi zmbd,

Recipe_Sub is an actual form name. I don''t know how to fix the code so I can''t figure out how to debug....

Thanks,
Joe


我很少关注第45行(和46),它们有百分号。 SQL不会那么喜欢。
I''m a little concerned with line 45 (and 46) where they have a Percent Sign. SQL isn''t going to like that much.
展开 | 选择 | Wrap | 行号


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

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