Results 1 to 4 of 4
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365

    too few many parameters expected

    Hi Guy's hope everyone is safe and well

    Can you help with this one please ?

    I have 2 query's one is called qryPostCodes and the other is called qryPostCodesAll

    These are based on a Date from a combo box

    qryPostCodes has got a criteria "Planning" in the status field, when I open the query it returns all records that are planning for that date (it is set to group by) as there maybe more than 1 record with the same postcode and only needing to return 1 record per postcode
    qryPostCodesAll has got a criteria "<> "Collection" Or "Collection Ready" in the status field, when I open the query it returns all records that are apart from the criteria for that date (it is set to group by) as there maybe more than 1 record with the same postcode and only needing to return 1 record per postcode

    When i run this through a recordset i am receiving runtime error 3061 too few many parameters expected 1.

    The reason i want to run through a recordset so it can start at the first record and loop through the postcodes and add to google maps to view locations

    Can anyone let me know where i am wrong ?

    Also, do i have the loop correct ? if not, please advise ?



    Kindest

    Code:
    Dim myPostCodes As String, MyURL As StringDim iQty As Integer, MyInput As Integer
    Dim rs As DAO.Recordset
    
    
    mPlan = "Planning"
    mDate = Format(Forms!frmMainMenu!frmIndex1!cboShipmentDateIndex1, "mm/dd/yyyy")
    
    
    MyInput = InputBox("Do You Want To View Map With:" & vbNewLine & vbNewLine & _
    "1" & vbTab & "What Is Left Planning" & vbNewLine & vbNewLine & _
    "2" & vbTab & "The Full Week", "ENTER MAP OPTION")
    
    
    Select Case MyInput
    Case 1
    iQty = DCount("PostCode", "qryPostCodes")
    Case 2
    iQty = DCount("PostCode", "qryPostCodesAll")
    End Select
    
    
    If MyInput = "1" Then
    Set rs = CurrentDb.OpenRecordset("qryPostCodes")
    Do Until rs.EOF
    rs.MoveFirst
    myPostCodes = rs.Fields("PostCode")
    MyURL = "https://www.google.co.uk/maps/dir/" & myPostCodes
    OpenFile = Shell("C:\Program Files\Internet Explorer\IEXPLORE.EXE " & MyURL, vbMaximizedFocus)
    Loop
    End If
    
    
    If MyInput = "2" Then
    Set rs = CurrentDb.OpenRecordset("qryPostCodesAll")
    Do Until rs.EOF
    rs.MoveFirst
    myPostCodes = rs.Fields("PostCode")
    MyURL = "https://www.google.co.uk/maps/dir/" & myPostCodes
    OpenFile = Shell("C:\Program Files\Internet Explorer\IEXPLORE.EXE " & MyURL, vbMaximizedFocus)
    Loop
    End If
    .......................................
    I Have now tried writing the Recordset and comes up with your query does not include Specified expression "ShipmentDate" as of an aggregate function
    I thought i had conquered this by changing the code as below ?

    Code:
    If MyInput = "1" ThenSet rs = CurrentDb.OpenRecordset("Select tblEdit.ShipmentDate, tblEdit.PostCode, tblEdit.Status From tblEdit " & _
    "WHERE ShipmentDate = #" & mDate & "# And Status = '" & mPlan & "' GROUP BY PostCode;")
    Do Until rs.EOF
    rs.MoveFirst
    myPostCodes = rs.Fields("PostCode")
    rs.MoveNext
    Loop
    MyURL = "https://www.google.co.uk/maps/dir/" & myPostCodes
    OpenFile = Shell("C:\Program Files\Internet Explorer\IEXPLORE.EXE " & MyURL, vbMaximizedFocus)
    End If
    Last edited by DMT Dave; 04-28-2020 at 03:08 AM. Reason: Changed Code

  2. #2
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Remove the tbledit.ShimentDate from your SELECT , and probably the status as well, as you haven't included that in the group by either, or add them to the grouping to include them in your output.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    thanks minty, how do i add them to the group by ? is it comma separations ?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Yes, separated by commas.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Too few parameters. Expected 1.
    By SierraJuliet in forum Programming
    Replies: 17
    Last Post: 02-01-2019, 02:28 PM
  2. Too Few Parameters Expected 9
    By RunTime91 in forum Access
    Replies: 11
    Last Post: 05-31-2018, 07:10 PM
  3. too few parameters; expected 2
    By slimjen in forum Forms
    Replies: 13
    Last Post: 07-26-2012, 02:42 PM
  4. Too few parameters. expected 1.
    By seth1685 in forum Programming
    Replies: 1
    Last Post: 01-11-2012, 08:08 AM
  5. Too few parameters. Expected 2.
    By PPCMIS2009 in forum Access
    Replies: 0
    Last Post: 01-28-2009, 01:02 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
  •  
Other Forums: Microsoft Office Forums