'Copy' isn't available now...?

branston

Registered User.
Local time
Today, 19:31
Joined
Apr 29, 2009
Messages
372
Hi,

I have a form with a vba programmed button. It has been working fine for a while, but I came to use it today and it came up with the following:
Run-time error '2046':
The command or action 'Copy' isn't available now.

The only thing I have changed is that I have added a bit of tried & tested "timer" code around the original code - but I can't see how that would stop it from working!

The code I have is is a simple, open -> copy -> close:

DoCmd.OpenTable "TblJdeWeeklyDetailTEMP"
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdCopy
DoCmd.Close acTable, "TblJdeWeeklyDetailTEMP"

The error highlights the 3rd line when you run the debug.

Any ideas?
 
What are you trying to actually do with the copying? There may be a better way (in fact I'm sure there is).
 
OK... background info...!
I have a table with all the data about the hours people have worked since the start of the project, with a marker in there for what week the hours were worked.
I need to add to this table every week, so I import the data from our hours system into a temporary table.
Then I update the week marker and things like that for all the records in this temp table, before copying all the records into the main hours table.
(Thats where to copy comes in)

Does that make sense?
 
It makes sense but the way to do it is to use two QUERIES instead.

One Update query which places the week information in the temp table data and then an APPEND query to append the data from that temp table to the live table.
 
so I can't do it via vba? Any particular reason?
It's worked previously...
 
so I can't do it via vba? Any particular reason?
It's worked previously...
1. Queries are best when workiing with data.

2. Your VBA as you are saying isn't a "best practice" and like I said - with data you use Queries if possible as they are more efficient and then you don't need to open the table nor do you have to worry about clipboard problems, etc.

I am talking from 14 years of Access development/programming experience here, so hopefully I would know a bit of what is good to do. :D
 
Ok, thats cool. I shall put it in a query.

Thanks for your help.
 

Users who are viewing this thread

Back
Top Bottom