type mismatch with DLookup (1 Viewer)

hardik_088

Registered User.
Local time
Today, 11:56
Joined
May 31, 2011
Messages
82
Hi Experts,
I have table Laptops and i have description ,location,quantity ordered textbox in "Insert_Data " form. so i wan to check that if description and location textbox values are same as table value then it should update data otherwise insert new records in table and i have written code here for that so can you tell me where i am wrong because it said type mismatch error.

If (Forms!Insert_Data![Type].Value = "Laptops") Then

If DCount("Description", "Laptops", "Description = " & Chr(34) & Forms!Insert_Data.Description & Chr(34)) > 0 Then
If DLookup("Location", "Laptops", "Location = " & Chr(34) & Forms!Insert_Data.Location & Chr(34)) Then

DoCmd.RunSQL "UPDATE Laptops SET Laptops.[quantity ordered] = Laptops.[quantity ordered] + " & Forms!Insert_Data![quantity ordered] & " WHERE Laptops.Description = " & Chr(34) & Forms!Insert_Data.Description & Chr(34)
DoCmd.Close acForm, "Insert_Data"

Else

DoCmd.RunSQL "INSERT INTO Laptops ([requsition type],[type],[purchase requisition],Location,department,requestor,[suggested supplier],[quantity ordered],[part number] ,Description,[privincial tracking number],[po number],[status],[billing code],[itscc code],[itscc task number]) " & _
" VALUES (" & Chr(34) & Forms!Insert_Data![requsition type].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data![Type].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data![purchase requisition].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data!Location.Value & Chr(34) & ", " & Chr(34) & Forms!Insert_Data![Department].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data!Supplier.Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data![Requestor].Value & Chr(34) & "," & Forms!Insert_Data![quantity ordered].Value & "," & Chr(34) & Forms!Insert_Data![part number].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data!Description.Value & Chr(34) & ", " & _
" " & Chr(34) & Forms!Insert_Data![privincial tracking number].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data![po number].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data![Status].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data![billing code].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data![itscc code].Value & Chr(34) & "," & Chr(34) & Forms!Insert_Data![itscc task number].Value & Chr(34) & ")"
End If
End If
 

Users who are viewing this thread

Top Bottom