Missing Operator?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Private Sub cmdAdd_Click()
Dim updatesql As String
Dim Updated_Allowance As Currency
Updated_Allowance = Forms!frmadjustallowance.CurAllowance +
Forms!FrmAdjust.CurAdjust
updatesql = ("Update TblAllowances SET curAllowance = " & Updated_Allowance
& " WHERE tblallowances.strdriver = " & Forms!frmadjustallowance.strDriver &
"")
CurrentProject.Connection.Execute (updatesql)
MsgBox Forms!frmadjustallowance.strDriver & " has had His/Her allowance
updated to " & Updated_Allowance
DoCmd.Close acForm, "FrmAdjust", acSaveNo
Forms!frmadjustallowance.Requery
End Sub
 
If strdriver is a text field, you're missing the delimiters ...

& " WHERE tblallowances.strdriver = '" & Forms!frmadjustallowance.strDriver
& "'"

That's a single quote followed by a double quote after the "=", and a single
quote between two double quotes at the end.
 
Access Idiot said:
Private Sub cmdAdd_Click()
Dim updatesql As String
Dim Updated_Allowance As Currency
Updated_Allowance = Forms!frmadjustallowance.CurAllowance +
Forms!FrmAdjust.CurAdjust
updatesql = ("Update TblAllowances SET curAllowance = " & Updated_Allowance
& " WHERE tblallowances.strdriver = " &
Forms!frmadjustallowance.strDriver &
"")
CurrentProject.Connection.Execute (updatesql)
MsgBox Forms!frmadjustallowance.strDriver & " has had His/Her allowance
updated to " & Updated_Allowance
DoCmd.Close acForm, "FrmAdjust", acSaveNo
Forms!frmadjustallowance.Requery
End Sub


The line segment:

allowance " updated

Needs to be:

allowance updated

That extra quote mark throws it off.

(Note: I did not receive a missing operator error. I received a
"Compile error, Expected: end of statement.)


Sincerely,

Chris O.
 
Back
Top