Copy query results to the clipboard VBA

janz

Registered User.
Local time
Today, 15:50
Joined
Jan 25, 2008
Messages
44
Hi,
I'm trying to copy the outcome of a query to the clipboard.
as follows

DoCmd.OpenQuery "changeboard query", acViewNormal, acEdit
DoCmd.SelectObject acQuery, "CHANGEBOARD QUERY"
RunCommand acCmdCopy
DoCmd.Close acQuery, "Changeboard query", acSaveNo

It doesn't work because in the open query there is nothing selected.
If I select the lines by hand the copy command works fine.

However I can't find the command in VBA to select all the lines in the query.
Can anybody tell me how I can do that?
 
Found it the program now looks like this

DoCmd.OpenQuery "changeboard query", acViewNormal, acEdit
DoCmd.SelectObject acQuery, "CHANGEBOARD QUERY"

DoCmd.RunCommand acCmdSelectAllRecords

RunCommand acCmdCopy
DoCmd.Close acQuery, "Changeboard query", acSaveNo

Takes the complete query highlights it and sticks it on the clipboard.
 
Found it the program now looks like this

DoCmd.OpenQuery "changeboard query", acViewNormal, acEdit
DoCmd.SelectObject acQuery, "CHANGEBOARD QUERY"

DoCmd.RunCommand acCmdSelectAllRecords

RunCommand acCmdCopy
DoCmd.Close acQuery, "Changeboard query", acSaveNo

Takes the complete query highlights it and sticks it on the clipboard.

Thanks a lot for posting the working script on this thread! :D This is (almost) exactly what i am looking for!
The only slight difference i need is to copy the query results WITHOUT the column headings?
Anyone have an idea of how this could be done?
 
Thanks a lot for posting the working script on this thread! :D This is (almost) exactly what i am looking for!
The only slight difference i need is to copy the query results WITHOUT the column headings?
Anyone have an idea of how this could be done?
Hi. The way I would probably do it is stick the query result in a Textbox and then copy it to the clipboard.
 

Users who are viewing this thread

Back
Top Bottom