Solved On click produced error - changing macro to vba (1 Viewer)

Jordonjd

Member
Local time
Tomorrow, 00:12
Joined
Jun 18, 2020
Messages
96
Afternoon everyone,

I have a button on a form with a macro to open another form. This works fine.

I want to change this to vba, so i open the macro, delete it and save, remove macro event and add the vba..

when i save the form and click the button it pops up with the following:

1649077615065.png


Once this has happened, it does not matter what i do, the buttons will not work again. I have tried:

Deleting the button and creating a new button.
Compact repair,
Converting the forms macros to vba

nothing seems to be able to be done after that, no events will work on that form, do you think i need to build the form again from scratch?

Thanks for any advice in advance
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 07:12
Joined
May 7, 2009
Messages
19,169
do you have diacritic letters on your control names?
 

Jordonjd

Member
Local time
Tomorrow, 00:12
Joined
Jun 18, 2020
Messages
96
do you have diacritic letters on your control names?
all of the control names are normal, no strange letters or symbols.

The macro event works fine as well but I wanted to change it to vba, only once I change it does it go wrong
 

Jordonjd

Member
Local time
Tomorrow, 00:12
Joined
Jun 18, 2020
Messages
96
I just made a copy of the form and everything works fine.
Sorry I should have just tried that before posting.

I am not sure what was wrong with the original form but this seems to have fixed it, A quick rename and
everything is working as it should be.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 18:12
Joined
Feb 28, 2001
Messages
27,001
When you make a new copy of the form (and remove the old copy), you get rid of the structure AND the code that is associated with the form through its class module. If some of that code became corrupted, you just deleted the corruption. And in the copy process, Access will not copy anything it thinks was corrupted. Since it didn't barf on the copy, that suggests (but doesn't prove) that the problem was in the compiled code. This is something that MIGHT have been corrected by using the Access /decompile command-line option. But what you did also works, so no harm, no foul.


The link is to a description of the decompile process along with some explanations. If this kind of problem ever happens to you again, remember to ALWAYS work on a copy in case EVERYTHING goes south on you, but you might try this approach.
 

Jordonjd

Member
Local time
Tomorrow, 00:12
Joined
Jun 18, 2020
Messages
96
When you make a new copy of the form (and remove the old copy), you get rid of the structure AND the code that is associated with the form through its class module. If some of that code became corrupted, you just deleted the corruption. And in the copy process, Access will not copy anything it thinks was corrupted. Since it didn't barf on the copy, that suggests (but doesn't prove) that the problem was in the compiled code. This is something that MIGHT have been corrected by using the Access /decompile command-line option. But what you did also works, so no harm, no foul.


The link is to a description of the decompile process along with some explanations. If this kind of problem ever happens to you again, remember to ALWAYS work on a copy in case EVERYTHING goes south on you, but you might try this approach.

Thanks for the advice and the link, I've just a read through.
I will give this a try on a copy and see how it goes

Thanks!
 

Jordonjd

Member
Local time
Tomorrow, 00:12
Joined
Jun 18, 2020
Messages
96
@The_Doc_Man


Hi there, just a quick fyi.

I ran into a similar issue on another form, followed the steps on the link and it worked.

Thanks again for the info
 

Users who are viewing this thread

Top Bottom