Export Parameter Query to Text (1 Viewer)

Brian100x

New member
Local time
Today, 00:21
Joined
Jun 20, 2001
Messages
8
I have a query that I need to export to a .txt file. The query uses three fields from a form to identify which records to export. When I try to export the query to the .txt file I get a "Too few parameters. Expected 3". I know this is a result of the information from the form, when I hard code the information in place of the form text box reference, the query exports just fine.

Defining the parameters in the query does not solve the problem. I checked the Microsoft home page and the solution that they provide has two problems. First when the query is saved and reopened it changes the SQL so it makes a new table in the database rather then a new file. Second it always saves it as a comma delemimeted file. I need it saved as a tab delimited file.

Does anyone know how to solve this it has been drifing me nutts all day.

Brian
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 19:21
Joined
Feb 19, 2002
Messages
43,302
To fix the "too few parameters" problem, make sure that your parameter names EXACTLY match the form field names that they reference.

To fix the format problem, export the query ONCE manually and save the export spec. Then reference the export spec in your TransferText method.
 

Brian100x

New member
Local time
Today, 00:21
Joined
Jun 20, 2001
Messages
8
I tried defining the parametes in the query and that did not solve the problem. If I export the query to a Excel file I do not have an issue. This seems to be an Access limitation, Microsoft sugests using a query like this (in the Northwind.mdb sample)

SELECT * INTO [Text;FMT=Delimted;HDR=Yes;DATABASE=C:\;].[Employees#txt] FROM Employees WHERE [EmployeeID] = [Enter an EmployeeID];

the Micorsoft page for this is http://support.microsoft.com/search/preview.aspx?scid=kb;en-us;Q269671

This works except for the two issues that I mentioned in the previous post. I do have an Export template for this file, but I do not know how to integrate that into the SQL statement?
 

Users who are viewing this thread

Top Bottom