Results 1 to 9 of 9
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question Too Few Parameters

    I have the following code executing on the click event. For some reason I keep getting the error message "too few parameters". It always hangs up on the set rs1 = ... portion. When I open the query there are records in the query. I don't understand why I am getting the message.



    Code:
    Dim db As Database, RS As Recordset, rs1 As Recordset, rs2 As Recordset, rs3 As Recordset
    Set db = CurrentDb
    Dim Strmsg As String, Strtitle As String
    Dim IntStyle As Integer
    Dim stDocName As String
     
     
    DAO.DBEngine.SetOption dbMaxLocksPerFile, 40000
        
        Set RS = db.OpenRecordset("QryCCUAssignOpen", DB_OPEN_DYNASET)
        Set rs1 = db.OpenRecordset("QryCCUEmp", DB_OPEN_DYNASET)

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I assume the query has form parameters? If so:

    Too Few Parameters. Expected 1 Error Message

    or you can wrap the form references in the Eval() function.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    What is the SQl for the query QryCCUEmp?

    Does the query have any form references as parameters?

    If yes, then this is the problem. You will need to substiture the actual values into the query. You could use VBA code to built the SQL string or use VBA to modify the QueryDef.

  4. #4
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Here is SQL for QryCCUEmp. I do have a form reference, which is necessary. I'm not sure I follow what you are suggesting I do in VBA. I am not well versed in SQL in VBA. I can do simple select, delete, update and append queries in SQL but this is beyond my knowledge.

    Code:
    SELECT TblEmployees.Org_ID, TblEmployees.RACF_No, TblEmployees.LastName, TblEmployees.FirstName, TblEmployees.MI, TblEmployees.Phone, TblEmployees.Extension, TblEmployees.FaxNo, TblEmployees.Position, TblEmployees.ROType
    FROM TblEmployees INNER JOIN TblPositionNo ON TblEmployees.[PosNo] = TblPositionNo.[PosNo]
    GROUP BY TblEmployees.Org_ID, TblEmployees.RACF_No, TblEmployees.LastName, TblEmployees.FirstName, TblEmployees.MI, TblEmployees.Phone, TblEmployees.Extension, TblEmployees.FaxNo, TblEmployees.Position, TblEmployees.ROType
    HAVING (((TblEmployees.ROType)=[Forms]![AAfrmTeamSel]![txtTeamCode]))
    ORDER BY TblEmployees.LastName, TblEmployees.FirstName, TblEmployees.MI;

  5. #5
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    As Paul suggested, try this:

    Code:
    HAVING (((TblEmployees.ROType)=Eval([Forms]![AAfrmTeamSel]![txtTeamCode])))

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by HiTechCoach View Post
    As Paul suggested, try this:

    Code:
    HAVING (((TblEmployees.ROType)=Eval([Forms]![AAfrmTeamSel]![txtTeamCode])))
    I'm pretty sure the Eval() function will require the form reference to be enclosed in quotes.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    Like this:

    HAVING (((TblEmployees.ROType)=Eval("[Forms]![AAfrmTeamSel]![txtTeamCode]")))

  8. #8
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Great. That worked. Thank you.

  9. #9
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    You're welcome.

    Glad Paul and I could assist.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Too few parameters error.
    By stupesek in forum Forms
    Replies: 5
    Last Post: 09-15-2010, 09:27 AM
  2. Removing parameters
    By katrinanyc926 in forum Reports
    Replies: 1
    Last Post: 08-04-2010, 04:24 PM
  3. Replies: 3
    Last Post: 07-01-2010, 07:55 PM
  4. Why am I getting error: too few parameters?
    By cowboy in forum Programming
    Replies: 3
    Last Post: 03-24-2010, 10:13 AM
  5. Input parameters
    By GloriaLuz in forum Reports
    Replies: 0
    Last Post: 11-14-2005, 09:38 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums