|
Question : what is causing "too few parameters. Expect 1.
|
|
I am getting "Too Few Parameters. Expect 1" when I add a "where" clause to my SQL statement in my VB section.
I works fine without it...but I need the "where" statement. I checked my table and the SALE_YEAR and SALE_LOCATION are fields in the table.
I am getting the error in this line Set rs = db.OpenRecordset(strsql)
Here is the code:
Function AddTemp(saleyear As Single, salelocation As String) 'add settlement records to temp table MsgBox "Please Wait..." 'Declare Variables Dim db As DAO.Database Dim rs As DAO.Recordset Dim rstemp As DAO.Recordset Dim strsql As String Dim desc As String Dim amount As Long Dim hip As Double Dim Consignor As Double Dim partner As Double Dim closed As Double Dim check As Double Dim pdate As Date Dim tdate As Date Dim pcent As Double Dim price As Double strsql = "Select * from [Settlement] where ([settlement].[sale_year] = " & [saleyear] & " and [settlement].[Sale_location] = " & [salelocation] & ") order by [settlement].[ct_hip_no];"
' strsql = "Select * from [Settlement] order by [settlement].[ct_hip_no];"
'Initialize Variables Set db = CurrentDb() Set rs = db.OpenRecordset(strsql)
Set rstemp = db.OpenRecordset("TempSettlement")
Thanks...
|
|
Answer : what is causing "too few parameters. Expect 1.
|
|
strsql = "Select * from Settlement where sale_year = " & saleyear & " and Sale_location= " & salelocation & " order by ct_hip_no;"
The above assumes that sale_year and sale_location are numeric columns. If they are text, then surround the passed value with single quote marks, like this:
strsql = "Select * from Settlement where sale_year = '" & saleyear & "' and Sale_location= '" & salelocation & "' order by ct_hip_no;"
|
|
|