Click to See Complete Forum and Search --> : Copy Datagrid With Ctrl+C


Raptors Fan
September 18th, 2001, 06:07 PM
Hi,

If you run a query on ACCESS it is displayed in a datagrid. I then type Ctrl+A and Ctrl+C to copy the data from the datagrid into an Excel sheet. I was wondering how to set my VB datagrid to allow me to do the same.

Thanks,

RF

Laurent VOISIN
September 19th, 2001, 09:28 AM
Hi,

Try this :


private Sub CopyGrid1ToClipboard()

With Grid1
Clipboard.Clear
Clipboard.SetText .Clip
End With
End Sub

private Sub Grid1_KeyPress(KeyAscii as Integer)

'if the user made a selection
If (Grid1.col <> Grid.ColSel) Or (Grid.row <> Grid.RowSel) then
'CTRL + C = copy
If KeyAscii = 3 then
Call CopyGrid1ToClipboard
KeyAscii = 0
Exit Sub
End If
End If
End sub




Hope it helped.

Laurent VOISIN.