Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-time error 2498 Syntax error in update statement

Status
Not open for further replies.

dejanv

Programmer
Joined
Oct 9, 2002
Messages
4
Location
MK
In a form I have calculated field called Tax; Tax = (txtQuantity*txtPrice). On change event on txtQuantity (type Number) and txtPrice (type Currency) fields I’m updating column Tax in tblAccouns table using VBA:
DoCmd.RunSQL "Update TblAccounts SET Tax = " & Me.Tax & " Where Key = " & Me.Key
The problem is only when the value of Tax is a decimal number. Then the error is: “Run-time error 2498 Syntax error in update statement”.
I don’t know what is the problem. Can somebody help me?

Thanks in advance
 
If you're on different numeric formats than US, and use comma as decimalseparator, try:

[tt]...SET Tax = " & replace(cstr(Me.Tax),",",".") & " Where Key = " & Me.Key[/tt]

Else, I'd say using the on change is perhaps not the best event, since it would fire per each keystroke, might perhaps look into using the after update?

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top