Results 1 to 5 of 5

Thread: Query Trouble

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2003
    Posts
    117

    Query Trouble

    Hi, when I call rs.open I get the error: Too few parameters, Expected 1.

    VB Code:
    1. Dim cn As ADODB.Connection
    2.     Dim rs As ADODB.Recordset
    3.     Dim sql As String
    4.     Dim cboText As String
    5.    
    6.     Set cn = New ADODB.Connection
    7.     cn.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};" & _
    8.            "Dbq=h:\project\db1.mdb;" & _
    9.            "Uid=admin;" & _
    10.            "Pwd="
    11.     cn.Open
    12.     Set rs = New ADODB.Recordset
    13.     cboText = cboClass.Text
    14.     sql = "SELECT StudentName FROM tblStudents WHERE " & _
    15.                                 "StudentClass1 = " & Quotes(cboText) & " OR " & _
    16.                                 "StudentClass2 = " & Quotes(cboText) & " OR " & _
    17.                                 "StudentClass3 = " & Quotes(cboText) & " OR " & _
    18.                                 "StudentClass4 = " & Quotes(cboText) & " OR " & _
    19.                                 "StudentClass5 = " & Quotes(cboText) & " OR " & _
    20.                                 "StudentClass6 = " & Quotes(cboText) & " OR " & _
    21.                                 "StudentClass7 = " & Quotes(cboText) & " OR " & _
    22.                                 "StudentClass8 = " & Quotes(cboText) & " OR " & _
    23.                                 "StudentClass9 = " & Quotes(cboText) & " OR " & _
    24.                                 "StudentClass10 = " & Quotes(cboText)
    25.     MsgBox sql
    26.     rs.Open sql, cn2
    27.     rs.MoveFirst
    28.     Do While Not rs.EOF

    Any ideas?
    Last edited by ironhide; Feb 12th, 2004 at 08:07 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width