热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

具有可变数量的列的VBAAccess2003表-VBAAccess2003tablewithavariablenumberofColumns

IhaveatableinAccess2003VBAwith164columnsbutthedataIgethas181columnanditispossi

I have a table in Access 2003 VBA with 164 columns but the data I get has 181 column and it is possible that it will get bigger in the future. I need to know how to resize my table an to add extra colums during the runtime I know how to check how many colums I need so I just need to know how to resize my own table.

我在Access 2003 VBA中有一个包含164列的表,但我得到的数据有181列,未来它可能会变大。我需要知道如何调整表格大小以在运行时添加额外的列我知道如何检查我需要多少列,所以我只需要知道如何调整我自己的表。

thanks

7 个解决方案

#1


3  

Another option; rather than have a "short-fat" table with lots of columns, have a "tall-skinny" table with lots of rows:

另外一个选项;而不是有一个有很多列的“短胖”表,有一个“高瘦”表,有很多行:

Short-fat:

   ID
   FirstName
   LastName
   ...
   Amount

   1 Joe Smith   ... $123
   2 Bob Roberts ... $214
   3 Jim Black   ... $500

Tall-skinny:

   RecordID
   FieldNumber
   FieldName
   FieldValue

   1 1 FirstName Joe
   1 2 LastName  Smith
   ...
   1 n Amount $123
   2 1 FirstName Bob
   2 2 Lastname  Roberts
   ...
   2 n Amount    $214
   3 1 FirstName Jim
   3 2 LastName  Black
   ...
   3 n Amount    $500

This is good if you have a "stand alone" table that doesn't have to join with other tables, otherwise you're in for a world of pain.

如果你有一个“独立”表,不必与其他表连接,这是很好的,否则你将陷入痛苦的世界。

#2


3  

There is not much to base this on, but it sounds like a design problem. I would look at the data that is driving these additional columns and see if you can create a column to store it.

没有太多基础,但这听起来像一个设计问题。我会查看驱动这些附加列的数据,看看是否可以创建一个列来存储它们。

If the data is really that volatile, i would consider creating a new table with Key, FieldName, FieldValue as your columns. This way you wont have to change your reports, queries, import routines every time the data changes.

如果数据真的那么易变,我会考虑创建一个新的表,其中Key,FieldName,FieldValue作为您的列。这样,每次数据更改时,您都不必更改报表,查询和导入例程。

#3


2  

I don't have the reputation to comment, but to extend the short-fat vs long-skinny argument, i think its a good idea to start there. then you can create a crosstab query using the field that has the old field names as the column header. then write a make-table off of that query and you will have your table.

我没有评论的声誉,但是为了扩展短发和长期紧张的论点,我认为从一开始就是一个好主意。然后,您可以使用具有旧字段名称作为列标题的字段创建交叉表查询。然后从该查询中写下一个make-table,你将得到你的表。

#4


1  

Might be something here. I'd probably create a new table based on the old one, and with the extra columns from data source. Then I'd populate the new table from the two data sources. I'd do this if for no other reason than it means I keep the old data safe while making the new.

可能是这里的东西。我可能会根据旧表创建一个新表,并使用数据源中的额外列。然后我将从两个数据源填充新表。如果没有其他原因,我会这样做,这意味着我在制作新数据时保持旧数据安全。

#5


1  

If you are stuck with this poor design, you can use SQL to add columns as you need them:

如果您遇到这种糟糕的设计,可以使用SQL根据需要添加列:

strSQL="ALTER TABLE tblTable ADD COLUMN NewCol Text (25)"
CurrentDB.Execute strSQL,dbFailOnError

Or you can use the TableDef.

或者您可以使用TableDef。

#6


0  

the problem is that i don't have the rights to change the design the complete database is already created my job is just to impiment the reading of csv data but these dam... data need more colums than there were implimented by the previos programmer thats why i can't just delete the table and besides there are about 30 or 40 tables like the one i describet in the question thats why i asked for some kind of algorithm to change the amount of columns

问题是我没有权利改变设计已经创建了完整的数据库我的工作只是为了破坏csv数据的读取,但这些大坝...数据需要更多的colums而不是previos程序员所表示的这就是为什么我不能只删除表,而且还有大约30或40个表,就像我在问题中描述的那个,这就是为什么我要求某种算法来改变列的数量

but thanks for the fast awnser

但感谢快速的芒果

#7


0  

So are you looking for VB/VBA code to alter the table in the MDB? It sounds like that's what you're after -- something automated based on the incoming data. If you don't have permissions on the MDB file that's going to be hard to do, but I think what you're really saying is that you don't have the option to open the MDB in Access and modify it.

那么你在寻找改变MDB表的VB / VBA代码吗?这听起来就是你所追求的 - 基于传入数据自动化的东西。如果你没有MDB文件的权限,那将很难做到,但我认为你真正说的是你没有选择在Access中打开MDB并修改它。


推荐阅读
  • ShiftLeft:将静态防护与运行时防护结合的持续性安全防护解决方案
    ShiftLeft公司是一家致力于将应用的静态防护和运行时防护与应用开发自动化工作流相结合以提升软件开发生命周期中的安全性的公司。传统的安全防护方式存在误报率高、人工成本高、耗时长等问题,而ShiftLeft提供的持续性安全防护解决方案能够解决这些问题。通过将下一代静态代码分析与应用开发自动化工作流中涉及的安全工具相结合,ShiftLeft帮助企业实现DevSecOps的安全部分,提供高效、准确的安全能力。 ... [详细]
  • 使用Ubuntu中的Python获取浏览器历史记录原文: ... [详细]
  • 知识图谱——机器大脑中的知识库
    本文介绍了知识图谱在机器大脑中的应用,以及搜索引擎在知识图谱方面的发展。以谷歌知识图谱为例,说明了知识图谱的智能化特点。通过搜索引擎用户可以获取更加智能化的答案,如搜索关键词"Marie Curie",会得到居里夫人的详细信息以及与之相关的历史人物。知识图谱的出现引起了搜索引擎行业的变革,不仅美国的微软必应,中国的百度、搜狗等搜索引擎公司也纷纷推出了自己的知识图谱。 ... [详细]
  • 我们有(据我所知)星型模式SQL数据库中的数据文件。该数据库有5个不同的文件,扩展名为 ... [详细]
  • SpringBoot整合SpringSecurity+JWT实现单点登录
    SpringBoot整合SpringSecurity+JWT实现单点登录,Go语言社区,Golang程序员人脉社 ... [详细]
  • MySQL多表数据库操作方法及子查询详解
    本文详细介绍了MySQL数据库的多表操作方法,包括增删改和单表查询,同时还解释了子查询的概念和用法。文章通过示例和步骤说明了如何进行数据的插入、删除和更新操作,以及如何执行单表查询和使用聚合函数进行统计。对于需要对MySQL数据库进行操作的读者来说,本文是一个非常实用的参考资料。 ... [详细]
  • 本文介绍了如何在MySQL中将零值替换为先前的非零值的方法,包括使用内联查询和更新查询。同时还提供了选择正确值的方法。 ... [详细]
  • 本文介绍了如何使用Power Design(PD)和SQL Server进行数据库反向工程的方法。通过创建数据源、选择要反向工程的数据表,PD可以生成物理模型,进而生成所需的概念模型。该方法适用于SQL Server数据库,对于其他数据库是否适用尚不确定。详细步骤和操作说明可参考本文内容。 ... [详细]
  • Oracle Database 10g许可授予信息及高级功能详解
    本文介绍了Oracle Database 10g许可授予信息及其中的高级功能,包括数据库优化数据包、SQL访问指导、SQL优化指导、SQL优化集和重组对象。同时提供了详细说明,指导用户在Oracle Database 10g中如何使用这些功能。 ... [详细]
  • 本文介绍了Oracle数据库中tnsnames.ora文件的作用和配置方法。tnsnames.ora文件在数据库启动过程中会被读取,用于解析LOCAL_LISTENER,并且与侦听无关。文章还提供了配置LOCAL_LISTENER和1522端口的示例,并展示了listener.ora文件的内容。 ... [详细]
  • Android系统源码分析Zygote和SystemServer启动过程详解
    本文详细解析了Android系统源码中Zygote和SystemServer的启动过程。首先介绍了系统framework层启动的内容,帮助理解四大组件的启动和管理过程。接着介绍了AMS、PMS等系统服务的作用和调用方式。然后详细分析了Zygote的启动过程,解释了Zygote在Android启动过程中的决定作用。最后通过时序图展示了整个过程。 ... [详细]
  • python限制递归次数(python最大公约数递归)
    本文目录一览:1、python为什么要进行递归限制 ... [详细]
  • Java 11相对于Java 8,OptaPlanner性能提升有多大?
    本文通过基准测试比较了Java 11和Java 8对OptaPlanner的性能提升。测试结果表明,在相同的硬件环境下,Java 11相对于Java 8在垃圾回收方面表现更好,从而提升了OptaPlanner的性能。 ... [详细]
  • java drools5_Java Drools5.1 规则流基础【示例】(中)
    五、规则文件及规则流EduInfoRule.drl:packagemyrules;importsample.Employ;ruleBachelorruleflow-group ... [详细]
  • 云原生应用最佳开发实践之十二原则(12factor)
    目录简介一、基准代码二、依赖三、配置四、后端配置五、构建、发布、运行六、进程七、端口绑定八、并发九、易处理十、开发与线上环境等价十一、日志十二、进程管理当 ... [详细]
author-avatar
吾爱九-九九
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有