Hi. I have an unbound textbox on a form, and a combobox on the same form. I would like for any change in the combobox value to run an SQL statement and put the results in the textbox. I don't actually have a query, rather I am hoping to just run the SQL from within the VBA. Is this possible?
Either way, I am getting Run-Timeerror 3061: Too few parameters. Expected 2.
The SQL does work fine on it's own.
Here is the code I have in the on change event of the combo:
Code:
Private Sub Combo27_Change()
Dim db As Database
Dim rs As Recordset
Dim strSQL As String
strSQL = "SELECT Sum([Amount]) AS TotalPaidtoDate FROM CreditorPayments;"
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
Me.Text33.Value = rs!TotalPaidtoDate
End Sub
The line that catches is:
Code:
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
Any ideas?
Thanks.