[AccessD] Copy and paste records with no column names

Gustav Brock gustav at cactus.dk
Thu Aug 30 08:59:05 CDT 2012


Hi all

Found a lo-tech solution to this.

Create an unbound form.
Drag-n-drop into the form the table/query to copy from.
A subform control with the table/query is created.

Create a textbox and a button on the form.
The textbox can have zero height to make it not visible.
Apply this code to the button:

<code>
Private Sub btnCopy_Click()

    Dim strCopy     As String
    
    Me!txtCopy.Value = Null
    Me!subSalesWeek.SetFocus
    DoCmd.RunCommand acCmdSelectAllRecords
    DoCmd.RunCommand acCmdCopy
    Me!txtCopy.SetFocus
    DoCmd.RunCommand acCmdPaste
    
    strCopy = Me!txtCopy.Text
    strCopy = Mid(strCopy, Len(vbCrLf) + InStr(1, strCopy, vbCrLf, vbBinaryCompare))
    Me!txtCopy.Value = strCopy
    DoCmd.RunCommand acCmdCopy
    Me!txtCopy.Value = Null
    
End Sub
</code>

Click the button.
Click the pane where to paste the data.
Paste. 

/gustav

>>> gustav at cactus.dk 29-08-12 20:58 >>>
Hi all

I can run these commands:

  DoCmd.RunCommand acCmdSelectAllRecords
  DoCmd.RunCommand acCmdCopy

to select and copy all records from, say, an open query.
Then I can open a spreadsheet in Lotus Notes and paste in the records.

However, the first row is the column names ...
How can I prevent these from being pasted?

/gustav



More information about the AccessD mailing list