I have to copy a record from a recordset to the clipboard.
Anyone can help me?
Thanks.
Printable View
I have to copy a record from a recordset to the clipboard.
Anyone can help me?
Thanks.
try this - this bit will retrive a query to a clip board - hope it help.
(accsess data base)
Private Sub Form_Load()
Dim Db As Database
Dim Rec As Recordset
Set Db = DBEngine.Workspaces(0).OpenDatabase("c:\mydatabase.mdb")
Set Rec = Db.OpenRecordset("SELECT statment", dbOpenDynaset)
Clipboard.SetText (Rec.Fields("QueryResult").Value)
End Sub
what is "QueryResult"?
VB wants an index and using an index it copy only a single field not the entire record.
I don't understand, so please be more specific thanks.
Using ADO
dim cnn as ADODB.connection
dim ars as ADODB.recordset
set cnn = new ADODB.Connection
With cnn
.ConnectionString = whatever
.Open
End With
set ars = cnn.Execute("select code from mytable")
Clipboard.Clear
Clipboard.SetText (ars!code)
This will put the first code returned by the recordset onto the clipboard
The same method can easily be ported to RDO or DAO
Hope his helps
Tony
I always use DAO, so i'll try it.
Thanx
You could write out the whole recordset in a predefined format and write the whole thing as data to clipboard and then read back as data, and unparse it.
What else, XML is the BEST for this.
RK
IMHO the best way to do this is the GetString method in ADO (equivalent to RDO's GetClipString).
from the docs:
"Returns the Recordset as a string-valued Variant (BSTR)."
clipboard.settext rst.GetString(adClipString)