I'm building a database in Access, and I want to run an update query in vba
.
I know the syntax a little bit, but it's giving me a bug.
The problem is that I try to pass some values to him by means of two variables, and it seems that he does not recognize those variables well.
The variables are of integer type.
The error that jumps me is the following:
The '3075' error occurred at runtime: syntax error (operator missing) in the query expression 'Where TBL_Residual_Name.Id_Residual_Name ='
The fields in the table are of type integer. The Id_Nombre_Residuo
field is the primary key.
Can someone tell me where I'm wrong?
This is the code:
Private mIntIdResiduo, mIntTipoIdResiduo As Integer
Private Sub cmbTipoResiduo_Click()
Me.txtTipoResiduo.Value = DLookup("[N_Tipo_Residuo]", "TBL_Tipo_Residuo", "[Id_Tipo_Residuo] =" & Me.cmbTipoResiduo.Value)
mIntTipoIdResiduo = Me.cmbTipoResiduo.Value
SQL = "UPDATE TBL_Nombre_Residuos SET TBL_Nombre_Residuos.Tipo_Residuo = " & mIntTipoIdResiduo & _
"WHERE TBL_Nombre_Residuos.Id_Nombre_Residuo =" & mIntIdResiduo
DoCmd.RunSQL SQL
End Sub