|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Too few parameters. Expected 1
I have no experience , but I wrote this, in order to count
the records from qryWLFormToOwner when notNo = " & Me!cboSelectFakellos Private Sub cboSelectIdiotisTo_AfterUpdate() Dim sql As String Dim dbs As Database Dim rs As Recordset Dim cnt As String Set dbs = CurrentDb sql = "Select IDCard From qryWLFormToOwner Where notNo = " & Me!cboSelectFakellos Set rs = dbs.OpenRecordset(sql, dbOpenSnapshot) If Not rs.EOF Then rs.MoveLast End If cnt = rs.RecordCount Me.txtCount = cnt 'txtCount is a textbox in my Form Set dbs = Nothing Set rs = Nothing End Sub The Private Sum won't run, the message "Too few parameters. Expected 1" appears and when I press Debug the following line is shown yellow: Set rs = dbs.OpenRecordset(sql, dbOpenSnapshot) Is there an obvious mistake ? |
|
#2
|
|||
|
|||
|
Usually that error means you have mis-spelled a column name in your sql.
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#3
|
|||
|
|||
|
Thanks, I will check.
|
|
#4
|
||||
|
||||
|
There are other ways this error can trigger ...
Arguments for a connection string can vary depending upon what kind of connection it is. In the statement below, these are your arguements: Set rs = dbs.OpenRecordset(sql, dbOpenSnapshot) And the args and syntax you use can vary depending upon what type of data access you are using. Here is syntax for one of many ways to connect using "Microsoft ActiveX Data Objects" Set ObjConn = Server.CreateObject ("ADODB.Connection") Set rs1 = CreateObject("ADODB.Recordset") Set rs1 = mydb.OpenRecordset("SELECT * FROM myTable") Here is one using "Microsoft DAO 3.6" Dim db as DAO.Database, rs as DAO.recordset sql="SELECT * FROM myTable" Set rs = db.OpenRecordset(sql) Either way, if you are using VB you have to have the correct library selected in your project (Tools ... References) to go with the syntax you are using. If you have DAO 3.6 included and you use "Dim rs as recordset" You might be able to get away with it sometimes but sooner or later the chances are it will fail on the OpenRecordset method of the object and that failure can manifest itself as "too few paramaters, expected 1" since it's the "OpenRecordset" method that is expecting "the parameters". This can even pop up on code that used to work but no longer does on account of simply including another library in your project that ALSO uses the term "recordset" Now VB doesn't know which one you want unless you specify. Hope that helps! |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Too few parameters. Expected 1 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|