Skip to content
Advertisement

Access VBA SQL Update – Too few Parameters expected 1

I am new to access VBA.

I am trying to add 1 to all numbers in a field that are equal or greater than the value in text box [TP_Bld_OrderNum_Txt].

This is my code:

CurrentDb.Execute "UPDATE TP_Matrix " & _
      "SET TP_Matrix.Order_" & Me.TP_Bld_TP_Cbo & " = TP_Matrix.Order_" & Me.TP_Bld_TP_Cbo & "+1 " & _
      "WHERE TP_Matrix.Order_" & Me.TP_Bld_TP_Cbo & ">= Me.TP_Bld_OrderNum_Txt"

I get this error:

too few parameters expected 1

I believe it relates to the text box value.

If I replace Me.TP_Bld_OrderNum_Txt with a number, the query works fine.

I have the text box set up as a number.

Why doesn’t it recognize its value?

Advertisement

Answer

You provided Me.TP_Bld_OrderNum_Txt as a literal (as a fixed string) and not its value:
& ">= Me.TP_Bld_OrderNum_Txt"

Try this instead:
& " >= " & Me.TP_Bld_OrderNum_Txt.Value

Also, it is a good practice to use .Value to explicitely use the value of the control.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement