每次在父表上添加/更新记录时,将记录附加到另一个表 [英] Append record to another table every time a record is added/updated on parent table

查看:62
本文介绍了每次在父表上添加/更新记录时,将记录附加到另一个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基本的资产管理数据库,包含2个表(Assets和AssetMovements)。每次将新资产添加到Assets表或修改现有资产记录时,我都希望在AssetMovements表中创建新记录。

AssetMovements表用于记录事务。

我创建了一个追加查询,但是如何设置它以便每当点击Assets表单上的''Save''按钮时,它就会运行查询并将该记录追加到AssetMovements table?

谢谢。

I have a basic asset management database with 2 tables (Assets and AssetMovements). I want a new record to be created in the AssetMovements table every time a new asset is added to the Assets table or an existing asset record is modified.
The AssetMovements table is just there to record the transactions.
I have created an append query but how can I set it up so that whenever the ''Save'' button on the Assets form is clicked, it runs the query and appends on that record to the AssetMovements table?
Thank you.

推荐答案

在你的保存按钮'的OnClick事件中,把
In your Save button''s OnClick event, put
展开 | 选择 | < span class =codeLinkonclick =WordWrap(this);> Wrap | 行号


感谢您的回复Seth。我正在使用Access 2010,当我进入Save按钮的OnClick事件时,它只允许我构建宏,所以我找不到任何地方粘贴代码。我如何解决这个问题?
Thanks for your response Seth. I am using Access 2010 and when I go to the Save button''s OnClick event, it only allows me build macros, so I can''t find anywhere to paste the code. How do I get around this?


哦,好的。我不使用宏,但是我没有把你的宏转换为vba,而是在网上搜索如何在宏中执行代码。


因此,您需要打开宏,然后选择显示所有操作。然后,您需要在宏的底部添加一行。只需输入SetWarnings,然后按Enter键。将出现SetWarnings选项。将其设置为。添加OpenQuery的另一个操作。在查询名称字段中输入您的查询名称。向SetWarnings添加其他操作:是。


应该这样做。
Oh, okay. I don''t work with macros, but instead of taking you the long way around of converting the macro to vba, I searched online for how to do my code in a macro.

So you need to open your macro, and select Show All Actions. You then need to add a line at the bottom of your macro. Just type in SetWarnings and then hit enter. The SetWarnings options will appear. Set it to No. Add another action of OpenQuery. Enter your query name in the Query Name field. Add another action to SetWarnings: Yes.

That should do it.


这篇关于每次在父表上添加/更新记录时,将记录附加到另一个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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