Just try making the suggested change and seeing whether it works.
If it does, you're fine. If it doesn't, post back with what didn't work,
and
we'll see what we can do.
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
believe me, NO offense taken! learning SQL is at the top of my ToDo
list.
thank you for being specific about how and where to put the code. i
did
create the query using SELECT* for each of the tables instead of naming
each
field as there are a couple hundred fields. the query works great. is
that
going to cause a problem after inserting the SQL statement? do you
need
(or
even want) more info as to what my application is for/doing to better
understand where i'm at?
i've read a lot of responses by you and Gunny and my opinion is, i
couldn't
be in better hands. thank you very much
:
What Gunny gave you is the SQL of a query that will do what you want.
Don't think of it as four lines of code: it's a single SQL statement
that
Gunny chose to display on four lines. No offense, but if you're going
to
work with Access, you really should learn SQL.
To adapt it to your situation, create a query that returns all of the
data
you want. Yes, you should specify specific fields, rather than use
SELECT
*,
in your query. Once the query is working how you want it to, go into
the
SQL
of the query (look under the View option on the menu when you've got
the
query open) and add the text
INTO [Text;HDR=YES;DATABASE=C:\Work\].Stuff.txt
before the FROM keyword of the query.
As you supposed, the INTO keyword tells Access to store a copy of the
data
retrieved "somewhere". The "somewhere" is defined by the combination
of
what's in square brackets and the .Stuff.txt afterwards. What Gunny's
got
will create a file named C:\Work\Stuff.txt that contains the data.
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
Gunny,
i'm one of those guys that likes to know why things work, not just
how.
can
you make sure i'm getting this right please.
CodeLine1: "SELECT" (this tells it that the data comes from a
query?),
",
ID" (field1?), ", Junk" (field2?). ", FromDate" (field3?), ....etc?
CodeLine2: "INTO" (what and where to put it?), "[Text (output
type?);
HDR=YES (don't know this?), "DATABASE=C:\Work\]." (where to put
it?),
"Stuff.txt" (what to call it?)
CodeLine3: "FROM tblStuff" (where did tblStuff come from?)
CodeLine4: "WHERE (ID<20);" (why a criteria clause? i want all of it
to
go.)
in CodeLine1 do i have to spell out every field with a comma in
between?
that could take awhile since the query selects all the fields from
six
tables
most of which have more than 20 fields.
this way when i screw things up i'll have a better idea of where to
fix
it.
:
Hi, Joe.
i'm trying to create a *.TXT file as an archive from the results
of
a
select
query before a delete query wipes out the information.
This is the syntax of the SQL query to save a SELECT query as a
text
file:
SELECT ID, Junk, FromDate
INTO [Text;HDR=YES;DATABASE=C:\Work\].Stuff.txt
FROM tblStuff
WHERE (ID<20);
The resulting text file will be C:\Work\Stuff.txt and will contain
three
columns of data, ID, Junk, and FromDate. The formatting of the
data
types
will be automatic, since Jet will automatically create a Schema.ini
file
in
the destination directory.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips and
tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for
contact
info.
:
i'm trying to create a *.TXT file as an archive from the results
of
a
select
query before a delete query wipes out the information. if i can
avoid
dumping it into a temporary table first then deleting the table
after
the
archive it would be nice. skipping unecessary steps is a cool
thing.
also,
can i bypass the select query and just output the results of the
delete
query
before the info is gone? not asking much huh
thanks