change value to table if record exist

hi,
yes i tried that code and its work but without date if i add date then not

can you check just (date )where i am wrong ?

code
DoCmd.RunSQL "INSERT INTO Laptops (Date,[requsition type],type,[purchase requisition],Location,department,requestor,[suggested supplier],[quantity ordered],[part number] ,Description,[privincial tracking number],[po number],[status],[received],[billing code],[itscc code],[itscc task number]) " & _
" VALUES ( " & "#" & Format(Forms!OrderLaptops![Date].Value, "mm/dd/yyyy") & "#" & "," & Chr(34) & Forms!OrderLaptops![requsition type].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![Type].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![purchase requisition].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops!Location.Value & Chr(34) & ", " & Chr(34) & Forms!OrderLaptops![Department].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![suggested supplier].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![Requestor].Value & Chr(34) & "," & Forms!OrderLaptops![quantity ordered].Value & "," & Chr(34) & Forms!OrderLaptops![part number].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops!Description.Value & Chr(34) & ", " & _
" " & Chr(34) & Forms!OrderLaptops![privincial tracking number].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![po number].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![Status].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![Received].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![billing code].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![itscc code].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![itscc task number].Value & Chr(34) & ")"


Thanks
You missed everything I said about DATE and TYPE needing to be in SQUARE BRACKETS.
 
Bob, you are right that i should not use reserved words but now i can't change beacuse it used lots of places.I also add []brackets but still

syntax error(3075)
it said syntax error in date in query expression '#'.

code
DoCmd.RunSQL "INSERT INTO Laptops ([Date],[requsition type],[type],[purchase requisition],Location,department,requestor,[suggested supplier],[quantity ordered],[part number] ,Description,[privincial tracking number],[po number],[status],[received],[billing code],[itscc code],[itscc task number]) " & _
" VALUES (" & "#" & Format(Forms!OrderLaptops![Date].Value, "mm/dd/yyyy") & "#" & "," & Chr(34) & Forms!OrderLaptops![requsition type].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![Type].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![purchase requisition].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops!Location.Value & Chr(34) & ", " & Chr(34) & Forms!OrderLaptops![Department].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![suggested supplier].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![Requestor].Value & Chr(34) & "," & Forms!OrderLaptops![quantity ordered].Value & "," & Chr(34) & Forms!OrderLaptops![part number].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops!Description.Value & Chr(34) & ", " & _
" " & Chr(34) & Forms!OrderLaptops![privincial tracking number].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![po number].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![Status].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![Received].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![billing code].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![itscc code].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![itscc task number].Value & Chr(34) & ")"

thanks
 
Is the field OrderLaptops.[Received] a date field too? If so, you need the octothorpes (#) instead of the Chr(34).
 
bob, I also tried that and i removed that field there is just one date field but eventhough same error

DoCmd.RunSQL "INSERT INTO Laptops ([Date],[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 (" & "#" & Format(Forms!OrderLaptops![Date].Value, "mm/dd/yyyy") & "#" & "," & Chr(34) & Forms!OrderLaptops![requsition type].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![Type].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![purchase requisition].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops!Location.Value & Chr(34) & ", " & Chr(34) & Forms!OrderLaptops![Department].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![suggested supplier].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![Requestor].Value & Chr(34) & "," & Forms!OrderLaptops![quantity ordered].Value & "," & Chr(34) & Forms!OrderLaptops![part number].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops!Description.Value & Chr(34) & ", " & _
" " & Chr(34) & Forms!OrderLaptops![privincial tracking number].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![po number].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![Status].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![billing code].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![itscc code].Value & Chr(34) & "," & Chr(34) & Forms!OrderLaptops![itscc task number].Value & Chr(34) & ")"

Thanks
 
bob , what we can do for combobox that user must have to choose any value from list.

Thanks
 

Users who are viewing this thread

Back
Top Bottom