Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Join Date
    Jan 2021
    Location
    Missouri Ozarks, USA
    Posts
    23

    Too few parameters. Expected 4. - Error occurs during export ot text but not to Excel

    Hello there,

    I have an export error that is leaving me stumped! I have a form with 4 controls that runs a parameter query. The query results appear to be correct. When I export the query to an Excel file, it works perfectly. When I try to export it to a text file, I get the error "Too few parameters. Expected 4". What's the difference. One suggestion I found online was to specify the parameters in the parameter box in the query design view. I tried that but I still get the error. If you need more information or the specific .accdb I can load it, but its a large file.

    Thanks in advance,

    canyonraven

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    I do not know why it works when going to Excel and not to text, but try this method.

    https://www.accessmvp.com/thedbguy/c...?title=generic
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I cannot replicate issue. Provide your code and sample data.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Join Date
    Jan 2021
    Location
    Missouri Ozarks, USA
    Posts
    23
    I am going to try attach a test db version of the database. It still generates the error above.
    Attached Files Attached Files

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    The ONLY query able to run works for me from the button?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2021
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,739
    How are you exporting? This worked fine for me.

    Click image for larger version. 

Name:	Buff.jpg 
Views:	17 
Size:	112.4 KB 
ID:	52507

  7. #7
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,927
    suggest take us through what you are supposed to do as I don't see any export button - only one that opens a query.

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    Quote Originally Posted by davegri View Post
    How are you exporting? This worked fine for me.

    Click image for larger version. 

Name:	Buff.jpg 
Views:	17 
Size:	112.4 KB 
ID:	52507
    I do get that error trying your method Dave.

    @canyonraven
    You have not even tried that function in the link I posted?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2021
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,739
    @canyonraven
    You have not even tried that function in the link I posted?
    There is not one single function in the db that you posted. There is no CODE to transfer to text or Excel. Have a look at what you posted.

  10. #10
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    Quote Originally Posted by davegri View Post
    There is not one single function in the db that you posted. There is no CODE to transfer to text or Excel. Have a look at what you posted.
    There is no DB in that link. Just a function that solves this issue.

    The following functions were from fellow MVP, Leigh Purvis (LPurvis). It automatically evaluates any parameters in your SQL when using the OpenRecordset (DAO) or the Open (ADO) method to avoid getting Run-time error '3061': Too few parameters.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  11. #11
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    You should change the query into a make-table query then export that new table.
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    canyonraven, I had no problem exporting manually to .txt with the wizard. There is no code for export to any format.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    Quote Originally Posted by June7 View Post
    canyonraven, I had no problem exporting manually to .txt with the wizard. There is no code for export to any format.
    Strange how I got the error?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Okay, get the error if I do not check "Export data with formatting and layout".

    I just tested VBA for TransferText to .csv and that works.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    Join Date
    Jan 2021
    Location
    Missouri Ozarks, USA
    Posts
    23
    I was trying to export the data from the query using the External Data ribbon button export to text. That was the point when the "Too few parameters..." error came up. I also get this same error when I right click and select Export to Text as shown in davegri's and Welshgasman's posts (#6 and # 8) above.

    Again, the really weird thing is that the error only comes up when exporting to text and not when exporting to Excel. It looks like the error is specific to the "Export Text Wizard". This is the error:


    Click image for larger version. 

Name:	Capture.JPG 
Views:	13 
Size:	20.2 KB 
ID:	52508

    Is anyone able to reproduce this error using the methods above?


Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 05-29-2023, 01:04 AM
  2. Replies: 9
    Last Post: 09-25-2018, 08:16 PM
  3. Replies: 1
    Last Post: 01-29-2013, 10:24 AM
  4. 3061 Error. Too few parameters. Expected 1.
    By rghollenbeck in forum Queries
    Replies: 5
    Last Post: 09-28-2011, 12:12 PM
  5. Replies: 1
    Last Post: 05-21-2011, 01:33 AM

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