Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2002
    Location
    Phoenix, AZ
    Posts
    122

    Unanswered: why wont this work!

    Set rec = db.OpenRecordset("SELECT * FROM tblIncomingMailLog WHERE tblIncomingMailLog.[Coordinator]= " & Forms!frmIncomingMailLog.OptionCoordinator.Text & " ORDER BY tblIncomingMailLog.[Date];", dbOpenDynaset)

    I keep getting an error message that says-

    runtime error "3061"
    to few parameters- expected 1


    Can someone help? Please

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Data type? If string you need to put quotes or apostrophes around the criteria ...
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Agree....
    Set rec = db.OpenRecordset("SELECT * FROM tblIncomingMailLog WHERE tblIncomingMailLog.[Coordinator]= " & chr$(34) & Forms!frmIncomingMailLog.OptionCoordinator.Text & chr$(34)& " ORDER BY tblIncomingMailLog.[Date];", dbOpenDynaset)


    Its so long since I last used DAO I've forgotten if you have specified the recordset type, or connection correctly. That could also cause problems

    Could I make a suggestions as 'good practise' you build your sql as a separate string - its easier for debugging purposes - I find it much easier to catch errors in the SQL by displaying the resultant string than trying to decipher If I've got the format right in the open statement

    eg
    Code:
    Dim strSQL as string
    strSQL="SELECT * FROM tblIncomingMailLog WHERE tblIncomingMailLog.[Coordinator]= " & chr$(34) & Forms!frmIncomingMailLog.OptionCoordinator.Text & chr$(34) & " ORDER BY tblIncomingMailLog.[Date];"
    Set rec = db.OpenRecordset(strSQL, dbOpenDynaset)
    HTH

  4. #4
    Join Date
    Dec 2002
    Location
    Phoenix, AZ
    Posts
    122
    I have added the quotes and now it seems to run but it does not filter the table like its suppose to. I have setup a form inwhich i would like the recordset to populate. How can i set the form's recordsource to populate to the filtered recordset?

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    forget the recordset.

    dim strSQL as string
    strSQL = "SELECT etc etc"
    forms!thisform.recordsource = strSQL

    (or me.recordsource = strSQL if the code is in the target form)

    izy
    currently using SS 2008R2

  6. #6
    Join Date
    Dec 2002
    Location
    Phoenix, AZ
    Posts
    122
    This worked Perfect- Thanks M OWEN and IZYRIDER!

  7. #7
    Join Date
    Dec 2002
    Location
    Phoenix, AZ
    Posts
    122
    Is it possible to transfer this recordset (rec) to a spreadsheet? I was able to create a form and set the recordsource to the strSQL variable but know i need to transfer this list to Excel- Can the transfer spreadsheet option work with a variable or recordset?

Posting Permissions

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