Select All on Filtered Record Set

M

Minikoop

I have the following code....it is for a select all botton on a
filtered record set on a subform.....but it's not working. I get the
following error, "too few parameters. Expected 1"

Private Sub Command34_Click()
Me.Refresh
Dim strFormvalue
Dim strSQL As String
strFormvalue = Forms!ActivityMaster!Combo11
strSQL = "UPDATE [tbl_YesNo] SET [tbl_YesNo].[Yes_No] = True WHERE
[tbl_YesNo].[AC] = [Forms]![ActivityMaster]![Combo11];"
CurrentDb().Execute strSQL, dbFailOnError
Me.Recalc
MsgBox "Reset Complete"
End Sub
 
D

Douglas J. Steele

Put the reference to the form outside of the quotes:

strSQL = "UPDATE [tbl_YesNo] SET [tbl_YesNo].[Yes_No] = True WHERE
[tbl_YesNo].[AC] = " & [Forms]![ActivityMaster]![Combo11]

if AC is a numeric field, or

strSQL = "UPDATE [tbl_YesNo] SET [tbl_YesNo].[Yes_No] = True WHERE
[tbl_YesNo].[AC] = " & Chr$(34) & [Forms]![ActivityMaster]![Combo11] &
Chr$(34)

if it's a text field.
 
K

Klatuu

The value you want to pass needs to be outside the quotes:
strSQL = "UPDATE [tbl_YesNo] SET [tbl_YesNo].[Yes_No] = True WHERE
[tbl_YesNo].[AC] = " * [Forms]![ActivityMaster]![Combo11] & ";"
 
Top