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

Change a recordset to a string. 2

Status
Not open for further replies.

DerickD

IS-IT--Management
Sep 19, 2002
93
LU
Hi all,

I have found some code on this site that can copy a string to the clipboard :

thread705-303001

It works great, just as it should.

But I am wanting to copy a recordset to the clipboard. For this to happen I would like to convert the record set into a string, and then I can add the string containing all the information to the clip board function.

Does any one know how to do this.

Thanks all,
DerickD

 
DerickD

You should be able to string variable together.

Example

dim strRecord as String

strRecord = me.field1 & ", " & me.field2

In this example, each field is spearated by a comma (,)

A couple of gotchas...

- You may want to test or accomodate for null variables
eg.
if not isnull(me.field2) then
strRecord = strRecord & ", " & me.field2
end if

If you are preparing the string for export, say to an Excel spreadsheet, you may have to maintain a place holder, i.e., ", " for null records.

- Adding memo fields and objects will not work well

Richard
 
The Stream Object might help...look in ADO help, it's fairly straighforward, and has methods to write out the stream, etc.
-jsteph
 
DerickD,

What are you trying to accomplish? If you give us some background, you'll likely get more than one suggestion of an easier way to go about whatever task it is.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Access Databases for Non-Profit Organizations

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Hi,

What Willir suggestion is a good work around. I have implemented this in the Project. But if there is a better solution then....

Ok JeremyNYC,
Here I go....

I have a Form, and in the Form in a ListBox, When I open the Form, the Rowsource is set for the List with an 'OnOpen' event with a query that takes its criteria from the OpenArgs that are passed to it from the previous form.

What the user would like to do is take the information that is displayed in the ListBox and copy it to there Clipboard, so they can paste it into excel, notepad, ....etc...

Is there any way of transferring the result in the ListBox to the clipboard?

Thanks for helping so far..

Derick.
 
Derick,

Well, if you've already loaded the recordset, youcould save some time by not loading it again and just getting the data from the listbox. I did this really quickly:

Private Sub Command7_Click()
Dim intCount As Integer
Dim strAllItems As String

For intCount = 0 To (Me!lbxYadda.ListCount - 1)
strAllItems = strAllItems & vbCrLf & Me!lbxYadda.ItemData(intCount)
Next intCount
MsgBox strAllItems
End Sub

You should be able to fix it up to get the othert columns without too much trouble.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Access Databases for Non-Profit Organizations

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
I tried this and it works great...Thanks alot!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top