?
Solved

Run time error '3061'

Posted on 2003-03-12
2
Medium Priority
?
152 Views
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
datOPERATOR108.Refresh
If datOPERATOR108.Recordset.RecordCount > 0 Then
datOPERATOR108.Recordset.MoveFirst
While Not datOPERATOR108.Recordset.EOF
 List1.AddItem datOPERATOR108.Recordset.Fields(0) & ""
 datOPERATOR108.Recordset.MoveNext
 Wend
 List1.Enabled = True
 End If
End Sub
0
Comment
Question by:indra_eva2002
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

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

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

instead....

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!
0
 

Author Comment

by:indra_eva2002
ID: 8126211
Thank you very much!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month10 days, 16 hours left to enroll

770 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