Results 1 to 2 of 2
  1. #1
    EvanScamman
    Guest

    Opening an ADO Recordset with SQL statement (a2k)

    I'm trying to use a SQL statement to open a Recordset. When I run the following code, I get this error:
    Run-time error: No value given for one or more parameters...

    Please show me what I'm doing wrong.
    Thanks!
    Evan


    -----------------

    Dim cn2 As ADODB.Connection
    Dim rst3 As ADODB.Recordset
    Dim strSQL As String

    Set cn2 = New ADODB.Connection
    With cn2
    .Provider = "Microsoft.Jet.OLEDB.4.0"
    .ConnectionString = "C:databasetest.mdb"
    .Open
    End With

    Set rst3 = New ADODB.Recordset

    strSQL = "SELECT DISTINCT [FirstName] & "" "" & [Lastname] AS Fullname, tblOrderRequest.OrderRequestLinkID " & _
    "FROM tblOrderRequest INNER JOIN tblEmployee ON tblOrderRequest.AuthorizerID = tblEmployee.EmployeeID " & _
    "WHERE (((tblOrderRequest.OrderRequestLinkID)=[Forms]![frmOrderRequest]![OrderRequestLinkID]));"

    rst3.Open strSQL, cn2, , , adCmdText

    ........

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Opening an ADO Recordset with SQL statement (a2k)

    I would suspect it's in this line:

    "WHERE (((tblOrderRequest.OrderRequestLinkID)=[Forms]![frmOrderRequest]![OrderRequestLinkID]));"

    Try changing it to this:

    "WHERE (((tblOrderRequest.OrderRequestLinkID)=" & [Forms]![frmOrderRequest]![OrderRequestLinkID] & "));"
    Charlotte

Posting Permissions

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