I have a sql statement:
"SELECT Field1,field2 FROM table WHERE field1="[FORM]![PARAMETER]"
I need to export this to a CSV file with header information.
How can I do this?
I've tried the below function "save_data()", but I get a "expression
expected 1 error", I think b/c text transfer does not support
parameters during export. In addition, no header information apppears
even though the specifications are set to.
Think I need to pass the parameter in the function, use the SQL to make
a recordset that then gets made into a CSV file. But I need help. I
don't know where to start.
Thanks
**************************************************
Function savedata()
On Error GoTo Err_export
Dim AString As String
Dim query As String
'already made query
queryname = "myquery"
AString = "export_data_"
DoCmd.TransferText acExportDelim, "specification1", queryname,
"C:\Temp\" & AString & Format(Date, "YYYY_MMDD") & ".csv"
Exit_export:
Exit Function
Err_export:
MsgBox Err.Description
Resume Exit_export
End Function 8 19530
Albert Kallal has code that does this. He's an MVP, so you can get his
web site address from www.mvps.org/access
or you could roll one yourself using Freefile and then print
statements... kinda tedious, though. but you could just loop through
the records of your query and then inside that loop through the fields
and output that to csv... tediuos, but not terribly hard.
HTH,
Pieter
Can you please give me the exact link, I can not seem to find the link.
In addition, I'm not really sure how to use Freefile, do you have
example code?
Thanks!
stop...@hotmail.com wrote: Can you please give me the exact link, I can not seem to find the
link. In addition, I'm not really sure how to use Freefile, do you have example code?
Thanks!
Oh, now I feel stupid. Tried to go to his website, and it appears to
be down... (Has anybody seen Albert around anywhere? I haven't seen
his posts in a while...) but, I do know for one thing, that he has
code that does all this stuff for you. Pass a table or query or (?)
SQL statement, and it outputs to CSV for you... It's all packaged into
a class so you can import it and use it.
Now to actually *find* the thing!
Double dumb, I am. Is the message not "Too few parameters, expected
n"? If so, read this article. http://www.mvps.org/access/queries/qry0013.htm
See if that doesn't solve your problem first... then if more drastic
measures are called for, we'll go from there. No sense in confusing
you further now if it's not necessary.
Pieter
(Hey, this village is *taken*!!!) pi********@hotmail.com wrote: Oh, now I feel stupid. Tried to go to his website, and it appears to be down... (Has anybody seen Albert around anywhere? I haven't seen his posts in a while...) but, I do know for one thing, that he has code that does all this stuff for you. Pass a table or query or (?) SQL statement, and it outputs to CSV for you... It's all packaged
into a class so you can import it and use it.
Now to actually *find* the thing!
Check out http://groups-beta.google.com/group/...d76ba87ff7fc0b
James A. Fortune st*****@hotmail.com wrote: I have a sql statement:
"SELECT Field1,field2 FROM table WHERE field1="[FORM]![PARAMETER]"
I need to export this to a CSV file with header information.
How can I do this?
I've tried the below function "save_data()", but I get a "expression expected 1 error", I think b/c text transfer does not support parameters during export. In addition, no header information apppears even though the specifications are set to.
Think I need to pass the parameter in the function, use the SQL to make a recordset that then gets made into a CSV file. But I need help. I don't know where to start.
Thanks ************************************************* * Function savedata()
On Error GoTo Err_export
Dim AString As String Dim query As String
'already made query
queryname = "myquery"
AString = "export_data_"
DoCmd.TransferText acExportDelim, "specification1", queryname, "C:\Temp\" & AString & Format(Date, "YYYY_MMDD") & ".csv"
Exit_export: Exit Function
Err_export: MsgBox Err.Description Resume Exit_export
End Function
This
"SELECT Field1,field2 FROM table WHERE field1="[FORM]![PARAMETER]"
should look like... if Field1 and parameter are numeric
"SELECT Field1, field2 FROM table WHERE field1=" & [FORM]![PARAMETER] &";"
or like this if text
"SELECT Field1, field2 FROM table WHERE field1='" & [FORM]![PARAMETER] & "';"
--
Ronald W. Roberts
Roberts Communication rw*@robcom.com
Thanks for the page, but I still can not find the item you are
referring to.
Any more help is apprecaited.
I read this article, but I think the "&" is there when using it within,
VBA, is this correct?
I'm trying to run the SQL direct for the query itself. The issue is
when I call the query direct form within Access, the query works great.
But when I use VBA's docmd.transfertext,
I get the error, I read somewhere that the transfer text feature can
not handle parameters. So I thought maybe using VBA to loop though the
recordset and build the CSV file, line by line would work, only I don't
know how to code it, as I've not written to a text file with VBA.
Thanks
I apprecaite all the help This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Kevin P |
last post by:
Hi News Group,
In an application written in C# and VS.Net using Dotnet Framework 1.1.4322
on XP and Win 2000 machines, we randomly get the error...
|
by: Preference |
last post by:
Hello,
I am developing a .NET application in managed C++. Until now we have
executed without problems in a lot of different computers. But a few...
|
by: donis |
last post by:
Hi i am doing a project for making a hotel management system in
Microsoft Access
I wantto make a hotel with 20 rooms
5 = suite
5= double
5=...
|
by: Neo Geshel |
last post by:
I have the two subs:
Sub UniqueHits()
Dim StrSQLQuery As String
Dim ObjAdapter as New OleDbDataAdapter()
Dim ObjDataSet as DataSet
StrSQLQuery...
|
by: Nicolas |
last post by:
Hello
I can already export my datagrid (not dataset because my datagrid has
rowfilters) to excel and word. But I can't seem to manage it to...
|
by: Martin Ho |
last post by:
Can someone help me with this please? I wasn't very clear in my old
post.
I have a program to copy files from one location to another, now I...
|
by: Vijaya P Krishna |
last post by:
Hi,
I have a .NET Windows Forms application, written in VB.NET and C#.
I am opening a URL from the application using Process.Start(). The URL...
|
by: JayDawg |
last post by:
If anyone is willing to provide some consulting pro-bono, or for a very
small charge I would really love the asistance.
If anyone can fix my...
|
by: shapper |
last post by:
Hello,
In have a class inside a compiled DLL where I have the following code:
' Create site map XML document
Dim siteMap As XmlDocument = New...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...
| |