473,379 Members | 1,539 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,379 software developers and data experts.

Clear clipboard use to fix PasteAppend error

6
I am using the following routine to copy a row and append it to the table. The user then changes appropriate information relevant to the current date.

I keep getting an error when using CopyPA macro as posted. The error: Action failed Condition: True Action Name: RunCommand Arguments: 38.

When I halt it, the message "the command or action 'PasteAppend' is not available now". Sometimes it will work, but then other times, I get the error. From what I found while searching for this error, the clipboard is full at the time and cannot accept anything more. I attempted to add a routine to clear the clipboard, and that doesn't seem to be working. Perhaps I don't have it defined correctly. Could someone look at this and tell me if I have the functions/sub correctly defined in the right location? Can you tell me why I am getting the error and if I am on the right track? I am using Access 2003.
CopyPA macro:
Expand|Select|Wrap|Line Numbers
  1.  
  2.  RunCommand SelectRecord
  3.  RunCommand Copy
  4.  RunCommand PasteAppend 
VBA:
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub CopyRecord_Click() 
  3. On Error GoTo Err_CopyRecord_Click
  4.  
  5. Dim stDocName As String 
  6. stDocName = "CopyPA" 
  7. DoEvents
  8. DoEvents
  9. DoEvents
  10. DoEvents
  11. DoCmd.RunMacro stDocName
  12.  
  13. Exit_CopyRecord_Click: 
  14. Exit Sub
  15.  
  16. Err_CopyRecord_Click: 
  17. MsgBox Err.Description 
  18. Resume Exit_CopyRecord_Click
  19. End Sub 
Feb 29 '12 #1

✓ answered by NeoPa

Kent T:
I think it is rather caveman to put in several DoEvents
I agree. Without closer contact with the project it's hard to know how best to handle, but if a single one doesn't do it then I'd be looking to see why.

PS. Be careful of what you retro-fit to the question (Post #1). Where changes represent the question as it should have been, then retro-fit avidly. Where they represent progress in the thread, then it's not so good an idea. You're obviously someone who picks up ideas well, so I'm sure this will make sense to you.

PPS. Another idea to consider might be to avoid the use of macros entirely. I'm not a fan anyway, but if all is VBA then you can predict the flow of the code, whereas with macros calling code, that's less clear. Just a thought.

11 3607
NeoPa
32,556 Expert Mod 16PB
The macro looks wrong to me. I don't work with macros ever anyway, but I somehow doubt what you have there makes any real sense. Multiple commands on the same line surely can't be right.

The code looks wrong in a number of places, but you should be able to see that for yourself if you follow the instructions in Before Posting (VBA or SQL) Code. If/when you have a situation with an error that isn't caused by easily avoidable errors (The link should help with that), then please post the details correctly as indicated and we'll see what we can do for you.
Feb 29 '12 #2
Kent T
6
Sorry, there were some formatting problems from pasting in the message. I have adjusted it. I will also look at the link provided. Thanks.
Mar 1 '12 #3
NeoPa
32,556 Expert Mod 16PB
Good job :-)

Line #25 of your code is still suffering from being impossible code though. The linked article should help with that, but if you're still stuck when your code is valid then repost it and we can look into it for you.
Mar 1 '12 #4
Kent T
6
Fixed again. The problem seems to be that the clipboard in Windows cannot respond fast enough, so I am trying the clear clipboard method. Is it possible that I need to utilize a delay between the copy and the paste?
Mar 1 '12 #5
NeoPa
32,556 Expert Mod 16PB
Try using DoEvents(). You can find all the details using Context-Sensitive Help.
Mar 1 '12 #6
Kent T
6
I will try that and see what happens.
Thanks for the suggestion.
Mar 2 '12 #7
NeoPa
32,556 Expert Mod 16PB
You're welcome.

PS. I like the way you fix the problems when found, rather than adding extra posts that only tend to confuse people reading the thread.

PPS. To format code the best way, add the closing [/code] tag to the end of the last line rather than on the following one. It saves an empty line at the bottom ;-) Also, within [code] tags, spaces are always shown as is and are the same width as all other chars, so they can be used to tabulate data, whereas TAB chars are useless for that.
Mar 2 '12 #8
Kent T
6
Updated code to utilize DoEvents. I have multiple instances because when testing it several times in a row (clicking quickly), the same issue appears. However, in actual use, probably only one record will be copied in a session, so this may not occur. I think it is rather caveman to put in several DoEvents, but until I learn more, it may do. I will continue to test it and repost.
Mar 2 '12 #9
NeoPa
32,556 Expert Mod 16PB
Kent T:
I think it is rather caveman to put in several DoEvents
I agree. Without closer contact with the project it's hard to know how best to handle, but if a single one doesn't do it then I'd be looking to see why.

PS. Be careful of what you retro-fit to the question (Post #1). Where changes represent the question as it should have been, then retro-fit avidly. Where they represent progress in the thread, then it's not so good an idea. You're obviously someone who picks up ideas well, so I'm sure this will make sense to you.

PPS. Another idea to consider might be to avoid the use of macros entirely. I'm not a fan anyway, but if all is VBA then you can predict the flow of the code, whereas with macros calling code, that's less clear. Just a thought.
Mar 2 '12 #10
Kent T
6
It's a good thought. I had it banging through my little brain all weekend, and dummy here found that the same commands are available in VBA that I was using in the macro. I have nixed the macro and changed the code to include DoCmd.RunCommand as needed. I was making it entirely too hard. Thanks for all your direction.
Mar 5 '12 #11
NeoPa
32,556 Expert Mod 16PB
Good to hear :-) There's no reason everyone should have to learn all the same lessons from scratch.
Mar 5 '12 #12

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

Similar topics

0
by: xyz | last post by:
I have a menu item to handle clipboard actions (cut, copy, paste). When I paste text that I copied from a Hungarian web page, the display looks normal on my RichTextBox, but the text retrieved from...
6
by: owen | last post by:
Generally speaking, what does it mean when I see a "button" with red text showing this message instead of the control I've dragged onto the web form in Design View.? (But the page works fine at...
5
by: Chris Mantoulidis | last post by:
Let's say I have this: std::string s1; std::cin >> s1; This will read s1 from cin until it finds a space (or a newline, whichever comes first). Okay this works. But when I want to continue...
2
by: zbcong | last post by:
hello in my program,i have following method,it copy a jpg file to clipboard,and works well: Private Sub CopyImage() Dim file As System.IO.Stream =...
6
by: John Lau | last post by:
Hi, I am looking at the MS KB Article 306355: HOW TO: Create Custom Error Reporting Pages in ASP.NET by Using Visual C# .NET This article describes how to redirect errors to a custom html...
3
by: badboybrown | last post by:
hello, I have used the advice on this site to clear a specific error when a report is generated without any data. Err_cmdLaunchItemsReport_Click: Select Case Err.Number Case 2501 Err.Clear...
1
by: nettleby | last post by:
The Microsoft site has confused me on this issue: http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/iisbook/c06_redirection.mspx?mfr=true Says that: "ASP automatically discards...
7
by: Newbie | last post by:
How do I clear the clipboard in VB.NET 2003? TIA Newbie
0
by: =?Utf-8?B?SHVtYW0=?= | last post by:
I am developing a windows service that reads from the serial port and then put the data read from the serial to the clipboard, so the client can use Ctrl + v to paste, I am using...
1
by: iammilind | last post by:
In one of my code, I was using vector<> for certain class. In one of my struct, I have 'const' member data. However, vector<>::clear() throws compile error with that:...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.