473,836 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Clear clipboard use to fix PasteAppend error

6 New Member
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
11 3637
NeoPa
32,584 Recognized Expert Moderator MVP
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 New Member
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,584 Recognized Expert Moderator MVP
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 New Member
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,584 Recognized Expert Moderator MVP
Try using DoEvents(). You can find all the details using Context-Sensitive Help.
Mar 1 '12 #6
Kent T
6 New Member
I will try that and see what happens.
Thanks for the suggestion.
Mar 2 '12 #7
NeoPa
32,584 Recognized Expert Moderator MVP
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 New Member
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,584 Recognized Expert Moderator MVP
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

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

Similar topics

0
2242
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 the clipboard is corrupted. For example, a U with double accent ( byte code x'FB' ) is replaced by a question mark in my txtEdit.Text after a Paste operation. It seems that the Clipboard.GetText() is changing the data. How is it possible to...
6
6129
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 runtime). Does it indicate a problem with References for example? Thanks Owen PS. replies cc'd by email appreciated. owen.southwood@mantix.com
5
12244
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 reading it reads what's left over in the cin, and well that's logical.
2
4679
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 = Me.GetType().Assembly.GetManifestResourceStream("ProductCatalog.Nwind.jpg") Clipboard.SetDataObject(System.Drawing.Image.FromStream(file), false) End Sub
6
3570
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 error page. All six steps in the article work just fine. Then at the end of the article, there is a little comment about redirecting errors to an aspx page (instead of an html page):
3
1763
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 Case Else
1
6316
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 any existing output in the buffer when you call Response.Redirect " But then the code example has a Response.Clear in, i.e. If Err.Number 0 Then
7
3856
by: Newbie | last post by:
How do I clear the clipboard in VB.NET 2003? TIA Newbie
0
1937
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 Clipboard.Clear(); Clipboard.SetData(DataFormats.Text, (Object)IDCard.FirstName); but for some reason it seems that the clipboard does not fill up with data. Is there any security restriction of calling the clipboard methods from the same thread that the windows...
1
2535
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: =========================================== struct Test { const string Str; Test(const string str) : Str(str) {} }; struct TestWrapper
0
9813
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9664
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10832
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10539
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10584
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10248
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6976
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4446
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.