使用命令按钮将数据从表复制到表 [英] Copy Data from Table to Table with Command Button

查看:71
本文介绍了使用命令按钮将数据从表复制到表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Access 2003清单数据库。当一台设备变坏时,我们将其丢弃并从数据库中删除它。我们一直在将记录复制到excel表格进行存储,因此我们记录了以前的设备。我试图使数据库更加用户友好,并保持Access中的所有数据,所以创建了另一个名为JunkedEquipment的表。我希望能够使用表单上的命令按钮将记录从Equipment表复制到JunkedEquipment表,然后从Equipment表中删除记录,并在此过程中给出一个确认消息框以确认复制和删除。


我对VBA不是很熟悉,过去两天一直在摸索这一点。我尝试用宏和查询来完成这个,但到目前为止还没有实现我的目标。


我能做到的任何想法或方法吗?


我感谢任何帮助。

I am working with an Access 2003 inventory database. When a piece of equipment goes bad we junk it and delete it from the database. We have been copying the record to an excel form for storage just so we have a record of the former piece of equipment. I am trying to make the database more user friendly and keep all of the data in Access so have created another table called JunkedEquipment. I would like to be able to use a command button on a form to copy the record from the Equipment table to the JunkedEquipment table and then delete the record from the Equipment table and in the process give a confirmation message box to confirm the copy and delete.

I am not very familiar with VBA and have been fumbling over this the past 2 days. I have tried accomplishing this with a macro as well as a query but so far have fallen short of my goal.

Any Ideas or ways I can make this happen?

I appreciate any help given.

推荐答案

你尝试了什么?


因为我对设置查询不是很了解,所以我没有尝试太多。我确实尝试了一个宏,并打开了一个带有确认信息的消息框。它已正确取消但不会运行。我以为我可以使用CopyObject和DeleteObject动作来完成这项工作,但也没有任何运气。我不确定这些行为是否适用于表格中的记录。


以下是我设置宏的方法。


动作:沙漏


动作:具有条件的StopMacro:MsgBox(你确定吗?,289,垃圾设备)<> 1

动作:CopyObject(不知道如何将记录直接转到另一张桌子。)


动作:删除对象


我有种感觉我不知怎的远离此基础的方法。
As I am not very knowledgable about setting up a query so I didn''t try too much with that. I did try a macro and had it bring up a message box with a confirmation. It properly cancelled but would not run. I thought I could use the CopyObject and DeleteObject action to make this work but haven''t had any luck with those as well. I am not sure if these actions will work with a record in a form or not.


Here is how I setup the Macro to date.

Action: Hourglass

Action: StopMacro w/ Condition: MsgBox("Are you sure?",289,"Junk Equipment")<>1

Action: CopyObject (Not sure how to direct record to another table.)

Action: DeleteObject


I have a feeling that I am somehow way off base with this.


此上下文中的对象引用表/表单/报告。您要做的是运行追加查询和删除查询。设置这两个查询,您可以从宏或VBA调用它们。
Objects in this context refer to tables/forms/reports. What you''re looking to do is to run an Append query and a Delete query. Get those two queries set up and you can call them from a macro or VBA.


这篇关于使用命令按钮将数据从表复制到表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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