UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Export Query With Form Parameters To .csv File    
 
   
skwilliams
post Jun 23 2011, 03:01 PM
Post #1

UtterAccess Veteran
Posts: 326
From: Indiana



I'm not sure if this is the right forum to post this question but.

I have a table with particular data that I want to export to a comma delimited file. The parameter values may vary daily.

I have a query which utilizes parameters from a form tied to a table so the parameters are stored. I'm viewing the query from within this form as a subform and it's working great.

Now the problem. I want to take these query results and export to a .csv file. I've tried this code
CODE
Private Sub btnProcessSamples_Click()
DoCmd.TransferText acExportDelim, , "qrySampleExport2", "G:\PODRiso\Sample Lists\Samples\Samples.csv", False
End Sub

, but it asks for the parameters already provided by the form. If I replace the query name with the name of the subform, I get this error.
Run-time error '3011'
The Microsoft Access database engine could not find the object 'subfrmSampleExport2'. Make sure the object exists and that you spell its name and the path name correctly.

Any ideas??
Go to the top of the page
 
+
LionelRoodyn
post Jun 23 2011, 03:20 PM
Post #2

New Member
Posts: 6



Try this.
Make the parameter query a make table query and then run your export from the created table. Then you wont need any parameters in the query you are using for the export to csv.
Go to the top of the page
 
+
vtd
post Jun 23 2011, 07:13 PM
Post #3

Retired Moderator
Posts: 19,667



QUOTE (LionelRoodyn @ Jun 24 2011, 06:20 AM) *
Make the parameter query a make table query and then run your export from the created table. Then you wont need any parameters in the query you are using for the export to csv.

Sorry but the method sounds like a lot of work that results in storing duplicate data which bloats the database file requiring cleaning up afterwards to me?

I am sure there are easier ways...

Go to the top of the page
 
+
vtd
post Jun 23 2011, 07:17 PM
Post #4

Retired Moderator
Posts: 19,667



1. Please post details of the Form, SubForm and Controls relevant to the Query and most important, the name of the SubFormControl that houses the "SubForm" [subfrmSampleExport2]. Please note that the name of the SubFormControl may be different from the name of the Form being used as the "Subform".

2. Please post the SQL String of the Query [qrySampleExport2]

Go to the top of the page
 
+
skwilliams
post Jun 24 2011, 08:53 AM
Post #5

UtterAccess Veteran
Posts: 326
From: Indiana



To make it easier to understand, I've created an Access database with all the relevant tables, queries and forms.

The table "tblMain" will accumulate new data daily. I will be changing the parameters for the needed export data periodically.

Currently, I'm only working with the tblMain (Samples) not the Catalog data in case you are wondering about the additional parameters on the form.

I hope this helps.

Thanks.

This post has been edited by skwilliams: Jun 24 2011, 09:00 AM
Attached File(s)
Attached File  Test.zip ( 546.89K ) Number of downloads: 1
 
Go to the top of the page
 
+
skwilliams
post Jun 24 2011, 09:48 AM
Post #6

UtterAccess Veteran
Posts: 326
From: Indiana



I figured it out. I just added [Forms]![frmCatSamProcessing]! to the switch in the query.

Thanks to everyone for their assistance.
Go to the top of the page
 
+
vtd
post Jun 24 2011, 10:47 AM
Post #7

Retired Moderator
Posts: 19,667



Incorrect reference to the Form Control in the Query was what I suspected and therefore I asked for the SQL String of the Query and details of the Form.

Glad you worked it out...

Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 23rd May 2013 - 02:46 AM