-----Original Message-----
Hi Nick,
I've just used this code:
DoCmd.OpenQuery "FOJ", acViewNormal, acReadOnly
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdClose
to copy the records returned by a query to the clipboard. The query
returns the field name and a dozen records; they are placed on the
clipboard as both plain text and RTF text (and perhaps in other formats)
and have pasted correctly into the five non-Microsoft applications I've
tried so far.
So I suspect the problem is with the particular non- Microsoft
application that you are using and the way it accesses the clipboard. It
could be that it's accessing the formatted text on the clipboard but
interpreting it incorrectly.
If the application allows, use Paste Special instead of Paste, and
select Unformatted Text (or similar).
Otherwise, you could use the VBA approach I suggested, which would to
put plain text on the clipboard without the formatted text (in which
case the only thing to paste will be plain text, and the application
will paste that for want of anything else).
Another approach, which should be possible but which I've never actually
tried, would be to use RunCommand as above, and then clear all but the
plain text version from the clipboard. This will require Windows API
calls or perhaps the Visual Basic Clipboard object.
Hi John,
Well if finely got it to copy to the clipboard without the
formatting, sort of. This work when pasting to Microsoft
applications but unfortunately when I paste into another
it has another fault. As in one of the previous posts the
result is;
20367034
20368823
10606540
1#0#6#1#
The difference is that now the word Order does not paste.
If I paste into Excel or Word first and then re-copy the
four numbers, they paste into my other application fine.
Do you have any suggestions?
Thanks
Nick
-----Original Message-----
Nick,
This is most likely because qDaily_Job_Sheets_Complete is
expecting two
parameters (probably criteria that determine what records
it should
return) but can't find them. Using OpenRecordset works
directly with the
Jet database engine, which doesn't know about Access
forms.
Assuming that's the case, I think there are two ways to
go.
1) Modify your code so that it builds a SQL statement
equivalent to the
query with parameters included and uses this to open the
recordset, e.g.
....
Dim strSQL As String
....
strSQL = "SELECT Number FROM MyTable " _
& "WHERE (SomeField = " & SomeVariable _
& ") AND (OtherField = " & OtherVariable _
& ");"
....
set rstR = DbEngine(0)(0).OpenRecordset(strSQL)
....
2) Use the existing query as the recordsource of a form
(this lets it
find its parameters in the usual way). Then, instead of
opening a new
recordset and iterating through that, just do the same
thing with the
form's RecordsetClone.
On Wed, 8 Dec 2004 05:51:29 -0800, "Nick"
The next
thing when I pressed the command button a Microsoft
Visual
Basic, Run-time error '3061': To few parameters.
Expected
2.
When I went to the De-bug this line was highlighted
Set rstR = DBEngine(0)(0).OpenRecordset
("qDaily_Job_Sheets_Complete") I don't know where to go
from here
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.
.
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.
.