Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting certain fields from queries 1

Status
Not open for further replies.

jmc014

Technical User
Nov 24, 2007
80
ES
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,
 
Hi,

How about a married bachelor or or a square circle?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
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
 
but seen a married man acting like a bachelor"

But his acting like a bachelor does not change the fact that he is married. ;-)

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

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
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.
 
 http://files.engineering.com/getfile.aspx?folder=f7abb1d4-24db-476c-a7e8-dd40c12a3ab3&file=MajP_SelectFieldsToExport.accdb
That is a Major contribution!

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
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
 
How doe you select which fields to keep? Not sure I understand.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top