问题描述
拥有一个包含2个基本表的Access2013数据库。 我需要将Table1中三个longtext字段中的577个字符复制到Table2中的单个longtext字段。 我需要这样做,因为Table2是一个可重复使用的表,每个月都会被清除
而Table1是主要的数据来源。 数据最初输入到表单上的4个纯文本字段中,并以纯文本形式存储在Table1的三个longtext字段中。 我尝试了一个Append查询,无论我如何将三个字段放在一起
(使用'&','+',concatenate())数据截断为255 chrs。 我看到在longtext字段中获得超过255个chrs的唯一方法是直接打开表并手动输入。
Have an Access2013 database with 2 basic tables. I need to copy the 577 characters from three longtext fields located in Table1 to a single longtext field in Table2. I need to do this because Table2 is a reusable table and gets cleared each month whereas Table1 is the main source of data. The data is initially entered into 4 plain-text fields on a form and stored as plain text in the three longtext fields of Table1. I've tried an Append query and no matter how I put the three fields together (using '&', '+', concatenate()) the data ends truncated at 255 chrs. The only way I've seen to get more than 255 chrs into a longtext field is to open the table directly and type them in manually.
我真的需要一个vba代码解决方案获取三个Table1 longtext字段并将它们连接为单个字符串(始终小于65K chrs)并将组合数据作为连续字符串放入Table2中的单个longtext字段而不截断。
我在网上搜索过,但没有找到有效的解决方案。 有人建议使用"ADODB.command"哪个不编译。 其他一些混乱的QueryDef也没有用。
I really need a vba code solution that takes the three Table1 longtext fields and concatenates them as a single string (always less than 65K chrs) and places the combined data into the single longtext field in Table2 as a continuous string without truncating. I've searched the web and haven't found a solution that's worked. Some suggested "ADODB.command" which doesn't compile. Others mess with QueryDef which also hasn't worked.
任何人都可以获得实际工作而无需添加引用,安装插件或是一个巨大的线索吗? 非常感谢。
Anyone got something that actually works without having to add References, install addins or is a huge cluge? Thanks very much.
推荐答案
CurrentDb.Execute "INSERT INTO Table2 ([Field1], [Field2], [Field3], [Field4]) SELECT [Field1], [Field2], [Field3], ([Field1] & [Field2] & [Field3]) FROM Table1", dbFailOnError
假设Table2具有所有三个原始字段,但添加第四个是前三个字段的串联。 如果 - 适合你的桌子和田野名称 - 不起作用,那么你的情况就是你没有告诉我们的
。
That assumes that Table2 has all three of the original fields, but adds a fourth that is the concatenation of the first three. If that -- suitably adapted to your table and field names -- doesn't work, then there's something about your circumstances that you haven't told us.
这篇关于Access2013将LongText从一个LongText字段复制到另一个LongText字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!