Selecting a Query (1 Viewer)

bgcogen

Registered User.
Local time
Today, 18:22
Joined
Apr 19, 2002
Messages
61
Hi!
Basically I need to know how to select a particular query in code, so I can copy all the records onto the clipboard. The query is called Car, so up until now I've been typing;

Sub Copy()

Car.Selection
Selection.Copy

End Sub

or

Sub Copy()

ActiveQuery.Selection
Selection.Copy

End Sub

Does anyone know how I do this???

Thanks,
Dec

P.s. - Unfortunitly due to the nature of the process I'm dealing with I Have to copy the Query records to the clip board.
 

simongallop

Registered User.
Local time
Today, 18:22
Joined
Oct 17, 2000
Messages
611
I don't think that you can select the whole query result, but no doubt someone will prove me wrong!! Why can't you export the query in rtf or txt or xls etc format?
 

bgcogen

Registered User.
Local time
Today, 18:22
Joined
Apr 19, 2002
Messages
61
I can't export the query like that because there are 2 sheets on the existing excel document that I use. Sheet 2 has formalues that refer to the data sheet 1.

It messes up the names and stuff :-(

D
 

simongallop

Registered User.
Local time
Today, 18:22
Joined
Oct 17, 2000
Messages
611
Why not treat your Excel side as two files. You can keep your present workbook as is but instead of having data in sheet1, place links in sheet1 refering to your exported spreadsheet. This way, as you will export using the same name, no probs on future exports and no probs with the calcs in sheet2. If you want to pass the spreadsheet to others, then you could even do it with the following:

1/ Change Sheet1 to link to the exported spreadsheet
2/ Call the file ProcTemplate.xls
3/ Place code in ProcTemplate under Sub Auto_Open() which does:
Copy and paste sheet1 data as values (removes the links and keeps the new value)
Save file as Proc_ddmmyy.xls or something unique like it.
Application.Quit

What this will do is create your spreadsheet whenever you export data from Access and open the template file, save it as todays date or whatever it is you choose and then quits Excel. Because you did the save as command your template file still exists and still links to your exported Excel file.

HTH
 

Users who are viewing this thread

Top Bottom