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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy all records from a from to the clipboard 1

Status
Not open for further replies.

marksnow

Programmer
Oct 30, 2002
39
0
0
AU
Hi

I have a sub form currently that is in datasheet view and I want to setup a command button that when clicked will copy all the records from the sub form into the clipboard.

I am essentially wanting to replicate going into the subform and pressing Ctrl + A (to select all records) and then Ctrl + C to copy them.

I have tried sendkeys with no luck..

Any suggestions???
Mark
 
How are ya marksnow . . .

. . . and this:
Code:
[blue]   DoCmd.RunCommand acCmdSelectAllRecords
   DoCmd.RunCommand acCmdCopy[/blue]

Calvin.gif
See Ya! . . . . . .
 
I knew it had to be something stupidly easy. Thank you very much Ace Man
 
marksnow! . . .

I don't answer stupid questions! [thumbsup2]

Calvin.gif
See Ya! . . . . . .
 
TheAceMan

Another quick one for you then =)

The code you gave works well however it copies in the column headings aswell. Any quick ideas on how to remove the headings?


This is how it is coming through:

Item Material # Customer Material No Qty UOM HigherLevel Plant Shipping Point Product Hierarchy Material Description Sales Text
100 NSCW 1 ASSEMBLY
101 2027476 1 100 Item 1
102 2008427 1 100 Item 2
103 2038353 1 100 Item 3
104 2044974 1 100 Item 4
200 2016642 1 Item 5
300 2053787 1 Item 6
400 2053602 1 Item 7
500 2053549 1 Item 8


And this is how I want it to come through:

100 NSCW 1 ASSEMBLY
101 2027476 1 100 Item 1
102 2008427 1 100 Item 2
103 2038353 1 100 Item 3
104 2044974 1 100 Item 4
200 2016642 1 Item 5
300 2053787 1 Item 6
400 2053602 1 Item 7
500 2053549 1 Item 8


Cheers
Mark
 
marksnow
Have you considered an append query?
 
marksnow said:
[blue]Any quick ideas on how to remove the headings?[/blue]
I had a feeling you'd be back for that. The answer is yes but it'll take quite a bit more code and possibly an API.

By chance are you pasting the data elsewhere in the DB?

If so [blue]Remou's[/blue] post is on the right track.

[blue]Your Thoughts? . . .[/blue]



Calvin.gif
See Ya! . . . . . .
 
Thanks for your responses...

Unfortunately not I will be pasting the data into a completely different program.

Aceman if you could point me in the right direction and I will do some research to see if I can get it working...

I will potentially want to throw another spanner in the works later and force it to copy say 10 records to the clipboard, let the user paste the data into the other program and then go back to access and click okay and it will copy the next 10 records... etc etc

Thanks again
Mark
 
marksnow . . .

My other idea is [blue]looping thru a recordset and packing a string variable[/blue] proper for all the records. The plus side to this is that you'll have [blue]full control over formatting[/blue]. The downside is [blue]slower speed[/blue] . . . as least I believe so as I havn't tested this yet.

When the string is fully packed you'll [blue]copy to the clipboard[/blue] with the following [blue]API[/blue]:

Copy variables/control contents to memory

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
That code works a treat... can use chr(9) to insert the tab delimiters etc so now just have to write some code to populate a nice long string and all should be good.

Thank you very much one again Aceman!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top