Form Event when switching between another windows program and Access

sxschech

Registered User.
Local time
Today, 07:17
Joined
Mar 2, 2010
Messages
808
I have a form where I would like to enable a button only when the clipboard contains a particular string/phrase. The purporse of the button is to paste data into a table and if the data isn't what is supposed to be pasted, don't want to inadvertently add it. When the form opens, if the phrase isn't in the clipboard, I set the button to enabled=false. Next I switch to the non-access program, in this example, Chrome browser. Copy some text, then switch back to Access. At this point, I tried the Form's GotFocus event as well as the Form's Click event and neither seemed to fire, so the code to test whether to enable is not run. Is there a different event or code needed to make this work?
 
Untested but try the activate event. Not sure if it works with an external program.
 
Tried your suggestion and it does not seem to work for external program. Activate works when switching between forms within access. I guess I'll need to figure out a different approach.
 
Sorry, I should have tested; I was afraid it might not work with an external program. Offhand I can't think of what would. Hopefully someone else can.
 
Could you use the Call Stack to see what events are used.?

Not something I have ever played with myself, but I seem to recall someone mentioning it a while back.?
 
I'm not familiar with it either.
 
FYI the form's focus event almost never fires because you do not see a lot of forms without any visible enabled controls.
If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur
 
I think I found an alternative solution. Rather than enabling and disabling the button, I put the if statement in the on click event of the text box. If the button is clicked and the expected string isn't found, it pops up a messagebox saying to go get the data and then click the button.
 
Not sure how using a timer would help for my application as I'm not having the data pasted into a textbox. The form only has a button on it, which runs code that parses the clipboard data into a recordset loop to append vbcrlf delimited text rows into a table. This saves me from the extra step of pasting what I copy. Appreciate your effort though and will save for future possibility.
 

Users who are viewing this thread

Back
Top Bottom