如何使用VBA在两个不同记录中的字段之间交换数据 - Access 2003 [英] How do I use VBA to Swap Data Between a Field in Two Different Records - Access 2003

查看:193
本文介绍了如何使用VBA在两个不同记录中的字段之间交换数据 - Access 2003的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为Access 2003中的两个不同记录创建代码以交换字段中的数据?我想在表单上创建一个按钮,允许我交换字段的数据。例如,如果我有一个名为asset的字段,我想同时将一条记录的资产字段信息与另一条记录中的资产字段信息交换。 record1资产字段信息转到record2资产字段信息,record2资产字段信息转到record1。这可能吗?

How do I create code to swap data in a field for two different records in Access 2003? I want to create a button on a form that will allow me to swap data for a field. For example, if I have a field named asset, I want to swap the asset field information for one record with the asset field information from another record at the same time. record1 asset field information goes to record2 asset field information and record2 asset field information goes to record1. Is this possible?

推荐答案

对于交换,你总是需要交换字段的临时存储空间。

您可以通过创建临时表或使用VBA并将temp字段存储在变量中来实现。

临时表方法是在清空的temptable中插入源表记录,接下来的移动目标表到源,最后将临时表记录移动到目标表。


得到这个想法?


Nic; o)
For a swap you''ll always need a temp storage of the field(s) to be swapped.
You can do this by creating a temp table, or by using VBA and store the temp field in a variable.

Temp table approach is to insert the source table record in the emptied temptable, next "move" the target table to the source and finally move the temp table record to the target table.

Getting the idea?

Nic;o)


是的,这是可能的。


虽然很难提供任何有意义的建议,但问题中没有更多信息。在发布之前确定一个正确的问题更有意义。
Yes it''s possible.

Without more information in the question though it''s hard to offer any meaningful advice. It makes more sense to determine a proper question before posting it.


让我看看我是否能做得更好。我有一个计算机数据库。有时,我们会从我们的库存中为另一个人分配一台电脑。我想拿一台分配给用户John的电脑并将其分配给Frank。与此同时,我想将弗兰克的电脑分配给约翰。这就是我所说的交换。提前致谢
let me see if I can do a better job. I have a database of computers. On occasion, we will assign a pc to another person from our inventory. I want to take a pc that is assigned to user John and assign it to Frank. At the same time, I want to assign Frank''s pc to John. That is what I mean by swap. Thanks in advance


这篇关于如何使用VBA在两个不同记录中的字段之间交换数据 - Access 2003的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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