Copying & Pasting Code? Code Not Recognised!

wjoc1

Registered User.
Local time
Today, 17:03
Joined
Jul 25, 2002
Messages
117
Hi,

I dunno has anyone come across this problem before - maybe I'm dreaming! I have noticed this happening in quite a few db's I've developed and used to pass it off as some quirky glitch.

I have been copying and pasting code from one form and using it in a second form. However it doesn't seem to "recognise" some of the copied procedures. For example I pasted the 1st forms OnError event code into the second form, compiled my vb, compacted and repaired my db and it wouldn't recognise the OnError code.

Then I went in and created it from scratch in the second form and only pasted the contents of the OnError procedure. It was identical to what I had before but now when I run the code it works. Absolutely identical, word for word.

I needed to create the code explicitly as copying and pasting it from another form didn't work. It was as if it wasn't there. I compiled and re-compiled, compacted, repaired, even restarted the machine tono avail.

Has anyone encountered this problem before, it's very disconcerting looking at perfect code behind a form and it ain't working for no good reason.
 
Thanks Pat,

I've had to resort to this I'm afraid but has anyone any clever way around this problem? It would be so much handier if I could just paste the bluddy code without having to create the same procedures/events over and over again

Liam
 
out of curiosity,
paste the code to a text file (notepad) and then copy and paste from there to the VBE.
 
Kodo,

No good I'm afraid! How do I put this... it seems to me that you have to force Access to create a fresh instance of the procedure before it'll recognise it.
 
Just an oddball thought:

When you paste the event code, do the controls have the same name?

If they do, you should at worst have to open the form in design mode, paste the code in the class module, then go to the applicable control and find the Events tab. If the named event isn't set up to contain [Event Procedure] then click in that tab and choose [Event Procedure].

If the controls don't have the same name, that is what is tripping you up.
 

Users who are viewing this thread

Back
Top Bottom