Full Version: Very confusing in 2 Update statement in VBA module
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
smyeong
Hi, all. I was l wondering what has been wrong with below coding? It gives runtime error 3464 : Data Type Mismatch in your criteria expression on the STRSQL2 statement.

Dim strMsg As String, stDocName As String, strSQL As String, strSQL2 As String

Me!DOid = Nz(DLookup("nextno", "tbl_doctype", "doctype = Forms![frm_salesDO]!frm_salesDO_detail.Form![ildct]"), 0) + 1
Me.DOid.Requery
strMsg = strMsg & "New Delivery Order will be created with number ! " & DOid
strMsg = strMsg & " "
If MsgBox(strMsg, vbQuestion + vbYesNo, "OK?") = vbYes Then
'do nothing

strSQL = "UPDATE tbl_doctype SET tbl_doctype.nextno= '" & Me.DOid & "' " & "WHERE (((tbl_doctype.doctype)='" & Forms![frm_salesDO]!frm_salesDO_detail.Form![ILDCT] & "'));"

strSQL2 = " UPDATE tbl_itemledger " & _
" SET tbl_itemledger.ILDOC = ' " & Forms!frm_salesDO.[DOid] & " '," & _
" tbl_itemledger.ILstatus = '565', tbl_itemledger.ILDCT = 'h9' , " & _
" tbl_itemledger.ILQTY = 0 -' " & [ILQTYship] & " ' " & _
" WHERE tbl_itemledger.ILstatus = '560' " & _
" AND tbl_itemledger.ILDCT = 'b5' Or tbl_itemledger.ILDCT = 'b6' " & _
" AND tbl_itemledger.ilsaleno = '" & [Forms]![frm_stock control].[trno02] & " ' " & _
" Or tbl_itemledger.ilsaleno = '" & [Forms]![frm_stock control].[trno03] & " ' " & _
" AND tbl_itemledger.ildate = '" & [Forms]![frm_stock control].[shipdate] & " ' ;"

CurrentDb.Execute strSQL, dbFailOnError
CurrentDb.Execute strSQL2, dbFailOnError
DoCmd.Close

Else
Me!DOid = Me.DOid.Value - 1
DoCmd.RunCommand acCmdUndo

End If


Hope someone could help out..
Thanks a lot,,,
yvesdekort
I think the problem comes form this :

" tbl_itemledger.ILQTY = 0 -' " & [ILQTYship] & " ' " & _

Shouldn't it be :

" tbl_itemledger.ILQTY = '0 - " & [ILQTYship] & " ' " & _

or

" tbl_itemledger.ILQTY = 0 - " & [ILQTYship] & _

depending on wether it's a textfield or a numercl field

Remember : ' are used for assigning to textfields, for numeric fields you don't need the '
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.