473,394 Members | 1,878 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

problem with CopyFromRecordset Access>Excel

Apologies in advance for this newbie question!

I have an Access form with an unbound embedded Excel chart on it(Called, OLEUnbound39) (Done on Access form by Insert > Object > Microsoft excel chart)
I would like to place some records in to the underliing sheet and display the chart of this data using VBA.
I use CopyFromRecordset. The code runs and the records are copied to the sheet, but apparently after this copy and before the next line in the code I get the following Error:

Run-time error ' -2147417851 (80010105)':
Method 'CopyFromRecourdset' of object 'Range' failed

This also happens if I change the recordset in a table recordset or if i copy not all the record or fields from the recordset.
The fields that are coupied are nothing special really (number autonumber, date and text fields)

Has anybody got any idea why i get the error and what I can do about it.
Both access and Excel on PC are 2003

Thanks

Code:

Private Sub Command40_Click()
Dim myWorkBook As Object
Dim myWorkSheet As Object
Dim myChart As Object
Dim db As DAO.Database
Dim rst As DAO.Recordset

Dim frm As Form

Set db = CurrentDb

Set myWorkBook = Me.OLEUnbound39.Object
Set myChart = myWorkBook.Sheets("chart1")
Set myWorkSheet = myWorkBook.Sheets(2)

Set rst = Me.Weight.Form.RecordsetClone
rst.MoveFirst
myWorkSheet.Activate
'myWorkSheet.Range("A20").CopyFromRecordset rst, rst.RecordCount - 1, rst.Fields.Count - 1
myWorkSheet.Cells(2, 1).CopyFromRecordset rst 'THIS LINE GIVES THE ERROR
rst.Close
myChart.SetSourceData Source:=myWorkSheet.Range("A1:B6"), PlotBy:=xlRows

End Sub
Dec 9 '07 #1
1 3398
So, I discovered that if I open excel manually from the start menu and minimalize it then returning to the access window and click the command button I do not get the error.

But, strangely, when i do get the error (so without the excel "trick") and click "end" on the error message, then open excel like discribed above and again click the button I do get the error.

So once I get the error access seems to "remember" this fact.

If I open excel with VBA in the code it does not prevent the error.

Still puzzelled!
Anybody any idea ?
Thanks
Dec 10 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Bryan Harrington | last post by:
Hello all.. I've got a table of data that PHB wants to be able to download to excel to run pivot tables on. No problem.. got all that working.. the catch though is that there is a column in the...
2
by: ExDelphi | last post by:
Hi All I am fairly new to VB.Net, and have gotten stuck with an invoicing application. My database (Access 2000 / 2003) is used to store records of our products, customers, suppliers etc. The user...
3
by: Gerry Blais | last post by:
Newbie questions: Suppose abc.xls has sheets a, b, c. How can I find, in Python, the sheet names? Given a sheet name, how can I export the sheet as a csv file? Finally, how can I, in...
10
by: Mark Day | last post by:
Hi All, I am using Access 2000 to generate over 40 Excel charts and pivot tables using early binding to the Excel 9.0 object library. I am finding that if I show the Excel object while processing...
2
by: Peter Malling | last post by:
The output from a HTML formmail gives a mail with the data for one record in this form: _ID=<Unique ID> <field1>=<value1> <field2>=<value2> .... Some fields might be undefined. How do I...
4
by: Chuck | last post by:
Hello, I have an Access XP database that has several fields. One of the fields is a text field and has an account number that is preceeded by a text character, like: F102354. Every account...
2
by: Japi | last post by:
My question is this: I have an access database with final numerical values and I'd like to link those results with an excel datasheet. I'd like to create a boton "compute" in the access document...
1
by: setterst | last post by:
I am quite new to VBA and Access, but I am trying to figure out how to export specific values from a table in Access, so I can save it in a given cell in Excel. I have been able to figure out how...
3
by: kenduron | last post by:
Hello together, I simply want to export table data to a new excel file without saving this file to local hard disk drive, the user should decide where to store. Alltogether, the excel sheet...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.