使用VBA对表中的每个字段执行操作 [英] Using VBA to perform action on every field in a table

查看:103
本文介绍了使用VBA对表中的每个字段执行操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是一名ICT学生,我正在设计一个与工作相关的项目,该项目使用MS Access 2007创建一个数据库来监控消防队员的休假。


我用SQL学习了关系数据库,但我已经足够新了Access。


班次模式遵循28天的周期。我有一个包含日期字段的表格


我的问题是:我如何使用VBA或以其他方式在此表中添加28天来创建新的日期表,而不必亲自动手。


提前致谢。


Alan

Hi,
I am an ICT Student and I am designing a work related project which is using MS Access 2007 to create a database to monitor leave for fire brigade staff.

I have studied relational database with SQL but am new enough to Access.

The shift patternns follow a 28 day cycle. I have a table with fields containing dates

My question is: how might I, using VBA, or otherwise add 28 days to this table to create a new table of dates, without having to do it manually.

Thanks in advance.

Alan

推荐答案

@irishalanm


艾伦。欢迎来到 Bytes


我不清楚你在桌子上加28天是什么意思。我相信我们可以帮助你(VBA有力量),但我们首先需要更清楚地了解你想要实现的目标。
@irishalanm
Hi Alan. Welcome to Bytes!

I''m not clear what you mean by adding 28 days to a table. I''m sure we can help you (VBA has the power), but we need a clearer understanding first of precisely what you''re trying to achieve.


Ok抱歉少了比清楚!


我想做的是将日期表中的每个日期提前28天。我想我必须设置一个循环,并且对于每个字段值,使用AddDate()函数为每个字段添加28,并在现有表中追加新值或创建新表,使原始日期不受影响。这有什么解释呢?


再次感谢


Alan
Ok Sorry about being less than clear!

What I want to do is advance each date in a table of dates by exactly 28 days. I suppose I would have to set up a loop and for each field value use the AddDate() function to add 28 to each and either append the new values in the existing table or create a new table, leaving the original dates unaffected. Does that explain it any better?

Thanks again

Alan


我会在SQL,但需要知道要调用的字段是什么(添加新记录时),以及确定在表中有多个重复项后要复制哪些记录的方法。


如何发布表结构以查看并解释在这种情况下,您希望如何识别需要复制的记录。
I would do it in SQL, but would need an idea of what the field to be changed is called (when the new record is added), as well as a way of determining which records to copy after there are a number of duplicates in the table.

How about posting the table structure to look at, and explaining, in that scenario, how you would want to identify the records that need to be copied.


这篇关于使用VBA对表中的每个字段执行操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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