1
Im使用后端JET数据库在Access 2010中工作,将值插入到该数据库中。访问数据库不接受使用VBA的具有特定值的插入
这不插入到数据库中(没有错误味精返回)
insert into [PROJECT RESOURCE UPDATE HISTORY] ([Current Date], [Project Auto No Ref], [Resource ID Ref], [Allocation Notes], [Allocation Role],[Usage Percentage - Oct], [Usage Percentage - Nov], [Usage Percentage - Dec], [Usage Percentage - Jan], [Usage Percentage - Feb], [Usage Percentage - Mar], [Usage Percentage - Apr], [Usage Percentage - May],[Usage Percentage - Jun], [Usage Percentage - Jul], [Usage Percentage - Aug], [Usage Percentage - Sep]) values (#2/13/2017 11:01:41 AM#, 540,11,'','Project Manager',0,1,1,1,1,1,1,0,0,0,0,0)
但这
insert into [PROJECT RESOURCE UPDATE HISTORY] ([Current Date], [Project Auto No Ref], [Resource ID Ref], [Allocation Notes], [Allocation Role],[Usage Percentage - Oct], [Usage Percentage - Nov], [Usage Percentage - Dec], [Usage Percentage - Jan], [Usage Percentage - Feb], [Usage Percentage - Mar], [Usage Percentage - Apr], [Usage Percentage - May],[Usage Percentage - Jun], [Usage Percentage - Jul], [Usage Percentage - Aug], [Usage Percentage - Sep]) values (#2/13/2017 11:04:38 AM#, 540,821,'','DevOps',0,0.13,0.13,0.13,0.13,0.13,0.13,0,0,0,0,0)
,这里是执行实际插入的代码片段
sqlStatement2 = "insert into [PROJECT RESOURCE UPDATE HISTORY] (" & _ "[Current Date], [Project Auto No Ref], [Resource ID Ref], [Allocation Notes], [Allocation Role]," & _ "[Usage Percentage - Oct], [Usage Percentage - Nov], [Usage Percentage - Dec], [Usage Percentage - Jan]," & _ "[Usage Percentage - Feb], [Usage Percentage - Mar], [Usage Percentage - Apr], [Usage Percentage - May]," & _ "[Usage Percentage - Jun], [Usage Percentage - Jul], [Usage Percentage - Aug], [Usage Percentage - Sep] " & _ ") values (" & _ "#" & Now() & "#," & _ rst![Current Project Ref No] & "," & rst![Current Resource Person ID] & ",'" & rst![Current Allocation Notes] & _ "','" & rst![Current Allocation Role] & "'," & CDbl(oct) & "," & CDbl(nov) & "," & CDbl(dec) & _ "," & CDbl(jan) & "," & CDbl(feb) & "," & CDbl(mar) & "," & CDbl(apr) & _ "," & CDbl(may) & "," & CDbl(jun) & "," & CDbl(jul) & "," & CDbl(aug) & _ "," & CDbl(sep) & ");" MsgBox (sqlStatement2) CurrentDb.Execute (sqlStatement2) rst.MoveNext
我相信在第一个例子中,问题围绕插入1到数据库中。数据库不报告错误,并且行不出现。如果将值从1更改为0.99,它会插入正确并显示在数据库中。我曾尝试 事情和看法:
我也曾尝试使用CDbl()函数我做insert语句在我的VBA代码之前,需要手动转换成1双。
如果我第一次插入后打破代码值1,行ID跳到像该行的下一个值插入
我还能在哪里看?
我敢打赌,如果您将1.0硬编码为可以工作的值。你的区域设置是什么,我想知道它是否将1,1,1解释为一个数字? – Minty
*“数据库不报告错误”* - 尝试使用'CurrentDb.Execute sqlStatement2,dbFailOnError'并查看它的行为是否有所不同。 –
@gordThompson对于dbFailOnError,我发现它是表本身的验证错误。谢谢! – Tino