附加到循环VBA代码的表 - 需要添加更多数据 [英] Append to a table looping VBA code - need to add more data
本文介绍了附加到循环VBA代码的表 - 需要添加更多数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在下面添加了2 str'。如何在保持循环语法的同时将它们添加到SELECT INTO中?表中的字段名称(tShipDetails)是Qty和StockID。
感谢任何帮助。
KM
I added the 2 str''s below. How do I add them into the SELECT INTO while still keeping the looping syntax? The field names in the table (tShipDetails) are Qty and StockID.
Any help is appreciated.
KM
展开 | 选择 | Wrap | 行号
推荐答案
@KashMarsh
@KashMarsh
- 为什么要将数量声明为字符串?
- 您的变量声明和分配被视为不同步。
- 为什么此代码在MouseUp()事件中执行?
- 说明以上内容,一般模板将是(语法未验证):
- Why are you Declaring Quantity as a String?
- Your Variable Declarations and Assignments seen to be out of sync.
- Why is this Code being executed in the MouseUp() Event?
- Stating the above, a General Template would be (Syntax not Verified):
展开 | 选择 | Wrap | 行号
ADezii谢谢为您的回复和专业知识。我非常感谢你。
回答你的问题:
1.应该使用lng而不是str,我只是不知道。
2.是的,我注意到strTons上的拼写错误 - 应该是严格的,但实际上应该是lngQty。
3.我更喜欢使用mouseUp而不是onClick,是否有一个更好的选择吗?
再一次,谢谢你给我的帮助很大。
KM
ADezii thank you for your reply and expertise. I really appreciate you.
To answer your questions:
1. lng should be used instead of str, I just didn''t know.
2. Yes, I noticed a typo on strTons - should be strQty, but really should be lngQty.
3. I prefer to use mouseUp instead of onClick, is there a better option?
Again, thanks you have helped me tremendously.
KM
ADezii,>
我得到运行时错误''3421''
数据类型转换错误。
突出显示这部分:
CurrentDb.Execute" INSERT INTO tShipDetails([StartDate],[Qty],[StockID])VALUES(#"& _
dteStartDate&"#",lngQty&",''"& strItemID&"'')"
StockID是一个数字数据键入表格,不确定是否是原因。
ADezii,
I''m getting a Run-Time error ''3421''
Data Type conversion error.
It''s highlighting this part:
CurrentDb.Execute "INSERT INTO tShipDetails ([StartDate], [Qty], [StockID]) VALUES (#" & _
dteStartDate & "#", lngQty & ", ''" & strItemID & "'')"
StockID is a number data type in the table, not sure if that''s the cause.
这篇关于附加到循环VBA代码的表 - 需要添加更多数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文