Syntax Error in Query Expression

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

I keep getting an Error "Synatx Error In Query Expression"
Its this Line:
MyRate = "UPDATE JobsEmp SET [Rate] = " & Me.TxtNewRate & " " & _

If Me.TxtHidden = 0 Then
DoCmd.OpenForm "NoEntry"
Else:
Me.TxtNewRate = Me.LabelDisplay.Caption
Dim MyRate As String
MyRate = "UPDATE JobsEmp SET [Rate] = " & Me.TxtNewRate & " " & _
"WHERE [EmployeeID] = " & Me.TxtEmpID & "And [JobID] = " &
Me.TxtJobID & ""
CurrentDb.Execute MyRate
DoCmd.Close acForm, "RatePad"
Forms!Employees.ListJobs.Requery
Forms!Employees.Visible = True
End If
Any Help Appreciated
Thanks
DS
 
DS said:
I keep getting an Error "Synatx Error In Query Expression"
Its this Line:
MyRate = "UPDATE JobsEmp SET [Rate] = " & Me.TxtNewRate & " " & _

If Me.TxtHidden = 0 Then
DoCmd.OpenForm "NoEntry"
Else:
Me.TxtNewRate = Me.LabelDisplay.Caption
Dim MyRate As String
MyRate = "UPDATE JobsEmp SET [Rate] = " & Me.TxtNewRate & " " & _
"WHERE [EmployeeID] = " & Me.TxtEmpID & "And [JobID] = " &
Me.TxtJobID & ""
CurrentDb.Execute MyRate
DoCmd.Close acForm, "RatePad"
Forms!Employees.ListJobs.Requery
Forms!Employees.Visible = True
End If
Any Help Appreciated
Thanks
DS
Problem Found.
MyRate = "UPDATE JobsEmp SET [Rate] = '" & Me.TxtNewRate & "' " & _
The Single Quotes Did the Trick.
DS
 
You're missing a blank before the keyword And: that means it would be
adjacent to whatever value you provide from Me.TxtEmpID (the "" at the end
isn't necessary, but I don't think it'll cause any problems)

What's the data type of EmployeeID and JobID? If they're text, you need to
put quotes around the value you're passing:

MyRate = "UPDATE JobsEmp SET [Rate] = " & Me.TxtNewRate & " " & _
"WHERE [EmployeeID] = '" & Me.TxtEmpID & _
"' And [JobID] = '" & Me.TxtJobID & "'"

Exagerated for clarity, that's

MyRate = "UPDATE JobsEmp SET [Rate] = " & Me.TxtNewRate & " " & _
"WHERE [EmployeeID] = ' " & Me.TxtEmpID & _
" ' And [JobID] = ' " & Me.TxtJobID & " ' "
 
Douglas said:
You're missing a blank before the keyword And: that means it would be
adjacent to whatever value you provide from Me.TxtEmpID (the "" at the end
isn't necessary, but I don't think it'll cause any problems)

What's the data type of EmployeeID and JobID? If they're text, you need to
put quotes around the value you're passing:

MyRate = "UPDATE JobsEmp SET [Rate] = " & Me.TxtNewRate & " " & _
"WHERE [EmployeeID] = '" & Me.TxtEmpID & _
"' And [JobID] = '" & Me.TxtJobID & "'"

Exagerated for clarity, that's

MyRate = "UPDATE JobsEmp SET [Rate] = " & Me.TxtNewRate & " " & _
"WHERE [EmployeeID] = ' " & Me.TxtEmpID & _
" ' And [JobID] = ' " & Me.TxtJobID & " ' "
Thanks, I'll figure this SQL out yet.
DS
 
Back
Top