By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,375 Members | 3,030 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,375 IT Pros & Developers. It's quick & easy.

Dlook up problem

P: n/a
I am getting error, RUN TIME ERROR 13, type mismatch
I have 2 tables. products and tblUpdates. My form frmProductUpdate is
assosiated with tblUpdates.I am trying to update quantity on hand. can
any one help plzz
Private Sub Quantity_AfterUpdate()
Dim TotalQty As Integer
TotalQty = DLookup("[Quantity]", "[Products]", "[ProductID]=" &
Forms![frmProductUpdate]![ProductID])
If (TotalQty - [QtyOnHand]) < 12 Then
MsgBox "Inventory Below 0. Quantity Issued is To High!"
Cancel = True
Exit Sub
End If
TotalQty = TotalQty - [QtyOnHand]
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE [Products] SET " & _
"[Products].[QtyOnHand] = " & TotalQty & _
"WHERE ((([Products].[ProductID])='" & [ProductID] & "'));"
DoCmd.SetWarnings True
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"a Khan" <ah******@hotmail.com> wrote in message
news:Iw***************@news.uswest.net...
I am getting error, RUN TIME ERROR 13, type mismatch
I have 2 tables. products and tblUpdates. My form frmProductUpdate is
assosiated with tblUpdates.I am trying to update quantity on hand. can
any one help plzz
Private Sub Quantity_AfterUpdate()
Dim TotalQty As Integer
TotalQty = DLookup("[Quantity]", "[Products]", "[ProductID]=" &
Forms![frmProductUpdate]![ProductID])
If (TotalQty - [QtyOnHand]) < 12 Then
MsgBox "Inventory Below 0. Quantity Issued is To High!"
Cancel = True
Exit Sub
End If
TotalQty = TotalQty - [QtyOnHand]
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE [Products] SET " & _
"[Products].[QtyOnHand] = " & TotalQty & _
"WHERE ((([Products].[ProductID])='" & [ProductID] & "'));"
DoCmd.SetWarnings True
End Sub

*** Sent via Developersdex http://www.developersdex.com ***


Looks to me like ProductID might be a text field, since you have quotes
around it in your UPDATE statement. You don't have quotes around it in the
DLookUP.

Nov 13 '05 #2

P: n/a
"a Khan" <ah******@hotmail.com> wrote in message
news:Iw***************@news.uswest.net...
I am getting error, RUN TIME ERROR 13, type mismatch


Somewhere along the way you are trying to make a join on fields of different
data types. Also, you will need to use quotation marks around text type
field names in your SQL.

Regards,
Keith.
www.keithwilby.com
Nov 13 '05 #3

P: n/a
no its not a text, it is actually an autonumber field. I made mistake
in UPDATE but it is giving me error TotalQty = DLookup("[Quantity]",
"[Products]", "[ProductID]=" &
Forms![frmProductUpdate]![Prod*uctID])

Nov 13 '05 #4

P: n/a
getting, error, 3075
Syntax Error (Missing Operator) in query expression '8WHERE
[Products].[ProductID]=1'
it is working now but now I am getting trouble at another line of code
in the same block

DoCmd.RunSQL ("UPDATE [PRODUCTS] SET [Products].[QtyOnHand] =" &
TotalQty & "WHERE [Products].[ProductID]=" & [ProductID] & ";")

AM i MISSING SOME THING

Nov 13 '05 #5

P: n/a
"khan" <ah******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
getting, error, 3075
Syntax Error (Missing Operator) in query expression '8WHERE
[Products].[ProductID]=1'
it is working now but now I am getting trouble at another line of code
in the same block

DoCmd.RunSQL ("UPDATE [PRODUCTS] SET [Products].[QtyOnHand] =" &
TotalQty & "WHERE [Products].[ProductID]=" & [ProductID] & ";")

AM i MISSING SOME THING


Yes you are. Look at the error message. It's telling you exactly what is
wrong. You are missing a space in front of the word WHERE.
Nov 13 '05 #6

P: n/a
Thanks Randy < I appoligize man I got my answer here I did not know that

Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.