Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Run time error '3061'

Posted on 2003-03-12
Medium Priority
Last Modified: 2010-08-05
When i click the cmdname i got this error :
"Run time error '3061,too few parameters.Expected1"
Thank you for help.
NOTE :when i click debug the pointer stop at datOPERATOR108.refresh (i think this line is the problem)

Private Sub cmdNAME_Click()
Dim sql As String
sql = "SELECT Name FROM OPERATOR108 WHERE  City = " & cboNAME.List(cboNAME.ListIndex) & " ORDER BY Name"
datOPERATOR108.DatabaseName = App.Path & "\OPERATOR108.mdb"
datOPERATOR108.RecordSource = sql
If datOPERATOR108.Recordset.RecordCount > 0 Then
While Not datOPERATOR108.Recordset.EOF
 List1.AddItem datOPERATOR108.Recordset.Fields(0) & ""
 List1.Enabled = True
 End If
End Sub
Question by:indra_eva2002
LVL 11

Accepted Solution

supunr earned 200 total points
ID: 8125586
try this...

List1.AddItem datOPERATOR108.Recordset.Fields(0) & ""


if (Trim("" & datOPERATOR108.Recordset.Fields(0)) <> "") then
    List1.AddItem "" & datOPERATOR108.Recordset.Fields(0) End if

apperently if the length of SQL is longer than 256 character you get this error message....
datOPERATOR108.RecordSource = sql ' refering to this line.
Refer MSDN article Q168194

oh, also correct your SQL to ....

sql = "SELECT Name FROM OPERATOR108 WHERE  City = """ & cboNAME.List(cboNAME.ListIndex) & """ ORDER BY Name"

city is a string, it must be put in between double quotes.

Good Luck!

Author Comment

ID: 8126211
Thank you very much!

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month11 days, 14 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question