VBA 类型不匹配错误
我不知道这是什么。显然它一定是某种语法错误,但我无法弄清楚它对我来说是什么!我所做的就是将数据保存到 SQL Server 2008 中的表中,并且我在 microsoft Dynamics Great Plains 2010 中使用 vba。它抛出错误的特定行是,
rs("FREIGHT_RATE") = frmItemProfile.txtFreightRate
但每当我进行调整时它似乎都会更改行,所以有这个方法可能在某个地方出了问题。错误消息只说“类型不匹配”任何帮助都会很棒。
Public Sub SaveRecord(strItemNumber As String)
Dim qry As String
Set rs = New ADODB.Recordset
'query table name
qry = "SELECT * FROM dbo.PCI_ITEM_PROFILE where ITEMNMBR = '" & strItemNumber & "'"
'open recordset
rs.Open qry, strDSNPCI, adOpenStatic, adLockPessimistic
If rs.EOF <> True Then
'Time to Update Record
rs("RCD_KEY") = frmItemProfile.txtRCDKey
If frmItemProfile.txtCopyRightDate = "" Then
rs("COPYRIGHT_DATE") = #1/1/1900#
Else
rs("COPYRIGHT_DATE") = frmItemProfile.txtCopyRightDate
End If
rs("FIRST_CATALOG") = frmItemProfile.txtFirstCatalog
rs("CATEGORY") = frmItemProfile.txtCategory
rs("SERIES_CD") = frmItemProfile.txtSeriesCD
rs("PARENT_CD") = frmItemProfile.txtParentCD
rs("TYPE") = frmItemProfile.txtType
rs("COMMODITY_CD") = frmItemProfile.txtCommodityCD
rs("BARCODE_1") = frmItemProfile.txtBarCodeOne
rs("BARCODE_2") = frmItemProfile.txtBarCodeTwo
rs("BARCODE_3") = frmItemProfile.txtBarCodeThree
rs("BARCODE_4") = frmItemProfile.txtBarCodeFour
rs("CLASS_GROUP") = frmItemProfile.cmbClassGroup
rs("FREIGHT_RATE") = frmItemProfile.txtFreightRate
rs("ITEM_LENGTH") = frmItemProfile.txtItemLength
rs("ITEM_WIDTH") = frmItemProfile.txtItemWidth
rs("ITEM_HEIGHT") = frmItemProfile.txtItemHeight
rs("USER2ENT") = frmItemProfile.txtUserEnt
rs("CREATE_DATE") = frmItemProfile.txtCreateDate
rs("MODIFDT") = frmItemProfile.txtModifyDate
rs("IN_KIT") = frmItemProfile.txtInKit
rs("IN_BOM") = frmItemProfile.txtInBom
rs("REP_COMM_PCT") = frmItemProfile.txtRepPct
rs("REP_COMM_EXCEPT") = frmItemProfile.txtRepCommExcept
rs("ROYALTY_ITEM") = frmItemProfile.txtRoyaltyItem
rs("PPC_PAGES") = frmItemProfile.txtPPCPages
rs("PPC_PAPER") = frmItemProfile.txtPPCPaper
rs("PPC_TONERCURVE") = frmItemProfile.txtPPCTonerCurve
rs("PPC_COIL") = frmItemProfile.txtPPCCoil
rs("PPC_IMPRESSIONS") = frmItemProfile.txtPPCImpressions
rs("DROP_SHIP_ITEM") = frmItemProfile.txtDropShipItem
rs("OP_CD") = frmItemProfile.txtOPCD
If frmItemProfile.txtOPDate = "" Then
rs("OP_DATE") = #1/1/1900#
Else
rs("OP_DATE") = frmItemProfile.txtOPDate
End If
rs("NOTES") = frmItemProfile.txtNotes
rs.Update
End If
rs.Close
Set rs = Nothing
End Sub
I have no clue what this is. Apparently it has to be some syntax error of some sort but I can not figure out what it is for the life of me! All I am doing is save data into a table in SQL Server 2008 and I am using vba in microsoft dynamics great plains 2010. The specific line it is throwing an error is
rs("FREIGHT_RATE") = frmItemProfile.txtFreightRate
but it seems to change lines whenever I make an adjustment, so there is probably something wrong in this method somewhere. The error message only says "type mismatch" Any Help would be amazing.
Public Sub SaveRecord(strItemNumber As String)
Dim qry As String
Set rs = New ADODB.Recordset
'query table name
qry = "SELECT * FROM dbo.PCI_ITEM_PROFILE where ITEMNMBR = '" & strItemNumber & "'"
'open recordset
rs.Open qry, strDSNPCI, adOpenStatic, adLockPessimistic
If rs.EOF <> True Then
'Time to Update Record
rs("RCD_KEY") = frmItemProfile.txtRCDKey
If frmItemProfile.txtCopyRightDate = "" Then
rs("COPYRIGHT_DATE") = #1/1/1900#
Else
rs("COPYRIGHT_DATE") = frmItemProfile.txtCopyRightDate
End If
rs("FIRST_CATALOG") = frmItemProfile.txtFirstCatalog
rs("CATEGORY") = frmItemProfile.txtCategory
rs("SERIES_CD") = frmItemProfile.txtSeriesCD
rs("PARENT_CD") = frmItemProfile.txtParentCD
rs("TYPE") = frmItemProfile.txtType
rs("COMMODITY_CD") = frmItemProfile.txtCommodityCD
rs("BARCODE_1") = frmItemProfile.txtBarCodeOne
rs("BARCODE_2") = frmItemProfile.txtBarCodeTwo
rs("BARCODE_3") = frmItemProfile.txtBarCodeThree
rs("BARCODE_4") = frmItemProfile.txtBarCodeFour
rs("CLASS_GROUP") = frmItemProfile.cmbClassGroup
rs("FREIGHT_RATE") = frmItemProfile.txtFreightRate
rs("ITEM_LENGTH") = frmItemProfile.txtItemLength
rs("ITEM_WIDTH") = frmItemProfile.txtItemWidth
rs("ITEM_HEIGHT") = frmItemProfile.txtItemHeight
rs("USER2ENT") = frmItemProfile.txtUserEnt
rs("CREATE_DATE") = frmItemProfile.txtCreateDate
rs("MODIFDT") = frmItemProfile.txtModifyDate
rs("IN_KIT") = frmItemProfile.txtInKit
rs("IN_BOM") = frmItemProfile.txtInBom
rs("REP_COMM_PCT") = frmItemProfile.txtRepPct
rs("REP_COMM_EXCEPT") = frmItemProfile.txtRepCommExcept
rs("ROYALTY_ITEM") = frmItemProfile.txtRoyaltyItem
rs("PPC_PAGES") = frmItemProfile.txtPPCPages
rs("PPC_PAPER") = frmItemProfile.txtPPCPaper
rs("PPC_TONERCURVE") = frmItemProfile.txtPPCTonerCurve
rs("PPC_COIL") = frmItemProfile.txtPPCCoil
rs("PPC_IMPRESSIONS") = frmItemProfile.txtPPCImpressions
rs("DROP_SHIP_ITEM") = frmItemProfile.txtDropShipItem
rs("OP_CD") = frmItemProfile.txtOPCD
If frmItemProfile.txtOPDate = "" Then
rs("OP_DATE") = #1/1/1900#
Else
rs("OP_DATE") = frmItemProfile.txtOPDate
End If
rs("NOTES") = frmItemProfile.txtNotes
rs.Update
End If
rs.Close
Set rs = Nothing
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个可能的重现:
我得到的错误:
Here's a possible repro:
The error I get: