×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Exporting certain fields from queries

Exporting certain fields from queries

Exporting certain fields from queries

(OP)
Hi,

Could do with a push here if anyone has got some ideas.
I have a series of quiries that return the results of a services table, all these queries have all the flieds from the the main table.

Later, all these quieries can be exported by the OutputTo command.
While this is working a treat, I would like to know how I can export ONLY FEW FIELDS from the same queries (without have to create new ones).

I need to export the same results from the already existis queries, but NOT all the data.

Any ideas would be appreciated.
Thanks,

RE: Exporting certain fields from queries

Hi,

How about a married bachelor or or a square circle?

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Exporting certain fields from queries

(OP)
Hi Skip,

Did`nt think it was possible, but it worth posting! (you never know)
Got around it by using creating a new table and then adding the data in a loop routine.

It's not as clean as would of hoped for, but it works!

Never seen a square circle before, but seen a married man acting like a bachelor!!!

Cheers anyway,
JMC

RE: Exporting certain fields from queries

"but seen a married man acting like a bachelor"

But his acting like a bachelor does not change the fact that he is married. winky smile

So you could design a fancy form for picking the fields to include or exclude and building the Select clause on command.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Exporting certain fields from queries

Here is a square circle for you.
The form does the following
1. You can choose any query from your database
2. The query is then shown in a subform
3. The multivalue listbox will show all the field names for the selected query
4. Click/unclick the columns you want to hide/show
5. Click the export button to save in excel

Basically there is a feature to show hide a field in a datasheet. I then look all the visible fields making a select statement from the selected query. I create a temp query def and export it.

You could build an insert query instead to "export" to a table.

RE: Exporting certain fields from queries

That is a Major contribution!

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Exporting certain fields from queries

(OP)
Thanks MajP, you got a star for that..

I used the below code that adds my results to a temp table that can then be exported out:

Function Append_ToTable() As Variant

Dim frm As Form
Dim subfrm As Control
Dim Rst As DAO.Recordset
Dim blnCheck As Boolean
Dim db As Database
Dim Re As DAO.Recordset
Set db = DBEngine(0)(0)

Set mainfrm = Forms!Main_Form!Annex
Set subfrm = mainfrm!DB_Annex
Set Rst = subfrm.Form.Recordset
blnCheck = Rst!Selection

Rst.MoveFirst
Do While Not Rst.EOF
With Rst

Set Re = CurrentDb.OpenRecordset("Annex_TMP", dbOpenDynaset, dbSeeChanges)
Re.AddNew

Re!ID_Service = Rst!ID
'Rest of my code goes here


Re.Update
db.Close

.MoveNext
End With
Loop

End Function



Thanks all the same for all your help, same highly appreciated.
JMC014

RE: Exporting certain fields from queries

How doe you select which fields to keep? Not sure I understand.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close