当将代码行扩展到下一行时,插入的错误会出错。 [英] When extending line of code to next line I get error with insert into.

查看:86
本文介绍了当将代码行扩展到下一行时,插入的错误会出错。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点像一个新手,但是大约10年前我确实做过编码,但是已经忘记了很多。我现在没有任何利润,并被要求帮助在MS Access中构建一个数据库,但是我从来没有在我的世界中使用过Access。真的是个新手!


我正在做的是构建一个from来将数据输入到表中。并且需要添加许多字段,因此单个语句有多行。当我将代码缩小到单行时,它也可以工作,如果我保持足够短,只有值。扩展我的代码工作,但当我扩展在插入到我收到一个错误,预计声明结束。

I am kind of a newb, however I did do coding back about 10 years ago, but have forgotten much. I now work for none profit and was asked to help build aDB in MS Access, however I never used Access back in my world. So really a newb!

What I''m doing is building a from to input data into a table. and there are many fields that need to be added, so there are multiple lines of a single statement. When I narrow the code down to a single line it works, also if I keep it short enough that just the "values" are extended my code works but when I extend in the "insert into" I get an error, expected end of statement.

展开 | 选择 | Wrap | 行号

推荐答案

欢迎使用字节.com!

我和其他许多人一样,我很乐意帮助非盈利。


感谢您使用第一次 [CODE /] 格式化工具。


不是故意的,我确实以最善良的方式打算这样做:
< b> OUCH


看起来您正在尝试将Access用作Excel工作簿...您不是第一个这样做,我用我的第一个数据库做了类似的事情 - 这是一个学习曲线。 :)


请您阅读以下文章。它将极大地帮助您完成项目。适当的桌面设计对于任何好的数据库都是VITAL!
home >主题> microsoft access / vba>见解>数据库规范化和表结构


从插入字符串我注意到你有 ALOT 数据中的非常个人信息......社会安全号码等内容不应以易于访问的格式存储。

至少,在某些时候,您只需启用数据库加密。更可取的是加密敏感数据字段。我已经在几个数据库中完成了这项工作,但这并不容易,只需要它。


你需要创建一个指向数据库的指针 - 使用 CurrentDB 一遍又一遍会在你进步时遇到一些问题。 Bytes.com上有几个主题讨论这个问题。基本上, CurrentDB 是一个特殊的构造,允许你创建一个指向数据库的指针,每次调用它时,它都会创建一个新的指针,这会导致内存泄漏,等...
Welcome to Bytes.com!
I''m always happy to help non-profits when I can as are many of the others here.

THANK YOU for using the [CODE/] formatting tool the first time out.

Not to be mean, I do intend this in the kindest way possible:
OUCH

It looks like you are trying to use Access as an Excel workbook... You are not the first to do this, I did something like this with my first databases - it''s a learning curve. :)

Would you please read thru the following article. It will help you tremendously with your project. Proper table design is VITAL to any good database!
home > topics > microsoft access / vba > insights > database normalization and table structures

From your insert string I notice that you have ALOT of very personal information in the data... such things as Social Security numbers should NOT be stored in easily accessible formats.
At the very minimum, at some point, you simply must enable the database encryption. More advisable would be to encrypt the sensitive data fields. I''ve done that in a few databases, it''s not easy to do but simply required.

You need to create a pointer to the Database - using CurrentDB over and over again will cause you some issues as you progress. There are several threads here on Bytes.com discussing this issue. Basically,CurrentDB is a special construct that allows you to create a pointer to the database, each time you call it, it creates a NEW pointer, which can lead to memory leaks, etc...
展开 | 选择 < span class =codeDivider> | Wrap | 行号


编码之前你可能已经知道多长时间和凌乱的名字让你的工作试图阅读和解释在你面前的代码是一场噩梦。像这样的一个领域让生活变得艰难。你所拥有的是教师在做作业时甚至不会开始考虑的事情。 在再次提交之前,先让它变得清晰 - 或者说是这样的话。


现在,在你的情况下,你自己需要处理结果,因此让你直截了当地做到这一点非常重要。更容易理解。使用任何无法工作的SQL时,您需要遵循如何调试SQL字符串。这很好,但是在目前状态下仍会让你感到难以理解的混乱。


因此,我建议你努力简化你的工作。与...合作。删除任何简单测试所不需要的字段;重命名名称过于复杂的字段(当你需要关注的是单个字段时,它们都很好,但是考虑理解一个字符串,其中包含很多如此冗长而多风的名字。);首先以最基本的形式测试它,并在上一级工作时添加任何复杂性(SELECT查询可以帮助您在将它们转换为任何类型的操作查询之前发现问题)。


但请记住,给我们提供一组代码,这些代码最终会在您的计算机上使用您选择的值创建一个SQL字符串,这对于帮助您调试该代码是相当无用的。很少有VBA代码甚至涉及到这个问题。在那些情况下,在尝试识别VBA中的任何错误之前,确定SQL问题的位置仍然有更多的意义。
Having coded before you probably appreciate how long and messy names make your job trying to read and interpret the code in front of you a nightmare. One field like that makes life difficult enough. What you have there is the sort of thing a teacher wouldn''t even start to consider when marking homework. "Go away and make it legible before submitting it again" - or words to that effect.

Now, in your case it''s yourself that needs to deal with the result so it''s particularly important for you to make it straightforward and easier to interpret. When working with any SQL that isn''t working you need to follow the ideas in How to Debug SQL String. That''s great, but in it''s current state that will still leave you with an incomprehensible mess.

Thus, I advise you to work in simplifying what you''re working with. Strip out any Fields that aren''t necessary for a simple test; rename Fields that have names that are too complicated (They''re all fine when all you have to focus on is a single Field, but consider understanding a string with many such long and windy names in.); test it in its most basic form first and add in any complexities when you have the previous level working (SELECT queries can help you find problems before converting them to action queries of any type).

Always remember though, giving us a set of code that ultimately creates a SQL string on your computer with your chosen values is fairly useless as far as helping you to debug that code. Very rarely is the VBA code even involved with the problem. On those occasions it is there is still much more sense in determining where the SQL problem is before trying to identify any error in your VBA.


这篇关于当将代码行扩展到下一行时,插入的错误会出错。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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