UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Dataobj.settext Question For Clipboard, Access 2007    
 
   
jysharp2003@yaho...
post Apr 3 2019, 07:44 AM
Post#1



Posts: 39
Joined: 23-January 19



Attached File  clipboardErro.jpg ( 57.07K )Number of downloads: 1
Hi Experts,
I have a button that works for the Hello World text below but I wanted the rs to be a SQL query output for clipboard and copy into another app like Google.
I get error attached. I have added FM20.dll to references (found on other posts) no success.
Thanks for your time and hopefully easy solution. Jerry


Private Sub CopyClipboard_Click()

Dim DataObj As New MSForms.DataObject
Dim rs As String

Set rs = db.OpenRecordset("SELECT email FROM loadconfigurations_email_union") ERRORS
'rs = db.OpenRecordset("SELECT email FROM loadconfigurations_email_union") ERRORS


'rs = "Hello World" WORKS
DataObj.SetText rs
DataObj.PutInClipboard

End Sub

Go to the top of the page
 
cheekybuddha
post Apr 3 2019, 08:01 AM
Post#2


UtterAccess VIP
Posts: 11,459
Joined: 6-December 03
From: Telegraph Hill


Hi,

Check you references (VBA editor -> Tools -> References)

Are any marked as missing?

Do you have the reference set to MSForms? I don't know which reference it would be frown.gif

d

--------------------


Regards,

David Marten
Go to the top of the page
 
jysharp2003@yaho...
post Apr 3 2019, 08:02 PM
Post#3



Posts: 39
Joined: 23-January 19



Hi there,
Here is a screenshot of what I have checked. Please let me know if you see any missing. Plus this application I am working on will be passed to users and maybe concerned that they would have to edit their references too.
My details shows that if I want to buffer text as Hello World it works. But my need is to copy buffer an output for SQL. I don't thing I have the right variable defined. Thanks again.
Attached File(s)
Attached File  clipboardErroReferencesChecked.jpg ( 76.98K )Number of downloads: 1
 
Go to the top of the page
 
theDBguy
post Apr 3 2019, 10:42 PM
Post#4


Access Wiki and Forums Moderator
Posts: 76,000
Joined: 19-June 07
From: SunnySandyEggo


Hi. You said Hello World works because probably SetText expects a Text or String but rs is neither; rather, it’s an object. What you could try is convert the result of rs into a String.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
WildBird
post Apr 3 2019, 11:13 PM
Post#5


UtterAccess VIP
Posts: 3,594
Joined: 19-August 03
From: Auckland, Little Australia


Youve declared rs as string, then trying to set it to a recordset.

What does the recordset return? How many fields and rows?

--------------------
Beer, natures brain defragging tool.
Go to the top of the page
 
WildBird
post Apr 3 2019, 11:14 PM
Post#6


UtterAccess VIP
Posts: 3,594
Joined: 19-August 03
From: Auckland, Little Australia


Just reread it. Do you want the results of the recordset,or the SQL to be copied?

CODE
Private Sub CopyClipboard_Click()

Dim DataObj As New MSForms.DataObject
Dim rs As String

'Set rs = db.OpenRecordset("SELECT email FROM loadconfigurations_email_union") ERRORS
rs = "SELECT email FROM loadconfigurations_email_union"


DataObj.SetText rs
DataObj.PutInClipboard

End Sub



--------------------
Beer, natures brain defragging tool.
Go to the top of the page
 
jysharp2003@yaho...
post Apr 4 2019, 08:34 AM
Post#7



Posts: 39
Joined: 23-January 19



Hi Bird,
I need the SQL output in clipboard.
Using your code snippet it seems to have a Format error. I searched on this error without success. Mostly Excel type hits.
Do you have a suggestion on this error?
I truly appreciate everyone's help on this. Users clicking a button to clipboard all current active emails to paste would be a great service.

Attached File(s)
Attached File  clipboardErroSTringApproachVBARowError.jpg ( 45.18K )Number of downloads: 1
Attached File  clipboardErroSTringApproach.jpg ( 22.07K )Number of downloads: 1
 
Go to the top of the page
 
jysharp2003@yaho...
post Apr 4 2019, 11:30 AM
Post#8



Posts: 39
Joined: 23-January 19



Hi All,
Found a solution using the code below. Seems to be an easier solution for my needs. I appreciate everyones time in finding a solution for me.
Take care.

DoCmd.OpenQuery "loadconfigurations_email_union", acViewNormal, acEdit
DoCmd.SelectObject acQuery, "loadconfigurations_email_union"

DoCmd.RunCommand acCmdSelectAllRecords

RunCommand acCmdCopy

DoCmd.Close acQuery, "loadconfigurations_email_union", acSaveNo
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    18th August 2019 - 01:54 AM