使用一个INSERT语句在Access 2003中插入多个记录 [英] Insert multiple records in Access 2003 using one INSERT statement

查看:105
本文介绍了使用一个INSERT语句在Access 2003中插入多个记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!这是我第一次在这里发帖,所以这里有。


情况:

我的表格有开始日期,结束日期,项目编号和总量。这些值是从另一种形式中提取的。然后,根据开始日期和结束日期之间的差异,该文本框的数量将其可见性设置为TRUE并显示在表单上。然后用户输入开始日期和结束日期之间每个月的数量。


问题:

我知道我可以将这些记录插入一个表一次使用一个循环,

Hi everyone! This is my first time posting here, so here goes.

THE SITUATION:
I have a form that has a start date, end date, project number, and total volume. These values are pulled from another form. Then depending on the difference between the start and end dates, that number of text boxes have their visibility set to TRUE and are displayed on the form. The user then enters volumes for each of the months between the start date and end date.

THE QUESTION:
I know that I can insert these records into a table one at a time using a loop,

展开 | 选择 | Wrap | 行号

推荐答案

两件事。 ..您可以关闭提示,询问用户是否要使用...追加一行...


DoCmd.SetWarnings False


只需确保在某处重新设置它。我通常将它设置回我的函数的Exit部分,以确保它会在出现错误时重新启动。


您可以使用单个insert语句插入多个记录插入和选择SQL查询。举个例子...

Two things... You can turn off the prompt to ask the user if they want to append a row using...

DoCmd.SetWarnings False

Just make sure you set it back on again somewhere. I usually set it back on the Exit portion of my function just to be sure it will be set back on if something Errors.

You can insert multiple records using a single insert statement using an Insert and a Select SQL query. So an example...

展开 | 选择 | Wrap | 行号


现在订阅...将稍后返回。
Just subscribing for now...will return later.


谢谢你Hype261,


关闭警告确实达到了预期的效果,现在是解决这个问题的最佳解决方案。


我试图让你编写的代码工作但是因为这些值不是来自任何表我不知道在FROM子句之后放了什么。此外,由于值都来自表单上的文本框,我不知道如何,1:收集所有可见的,以及2.将相同的项目编号附加到每个日期。


感谢您的回复。


Blake
Thank you Hype261,

Turning the warnings off did achieve the desired result and is now my best solution for this problem.

I tried to make the code that you wrote work but because the values are not coming from any table I dont know what do put after the FROM clause. Also since the values are all coming from text boxes on the form I am not sure how to, 1: Collect all the ones that are visible, and, 2. Attach the same project number to each of the dates.

Thank you for your reply.

Blake


这篇关于使用一个INSERT语句在Access 2003中插入多个记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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