Avatar of dgi001
dgi001
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Code not working in Access 2007

Hi

I am having difficulty with getting code to work when i copy it from a forms control event procedure to another forms control event procedure, where the code doesnt recognise the controls.

e.g. form CameraDataEntry has a save button called cmdSaveRec. This button contain an event procedure on the click command. I copied this code to the cmdSave Rect button event procedure on the form ComputerDataEntry. I then amended the code to reference the controls on that form. For some reason, the code will not reference the controls and just doesnt work or i receive messages such "Method or data member not found", even though it does. Is some instances i am having to rename controls to get this work e.g. a control name Firstname which is on both forms, will not work in form ComputerDataEntry (the form i copied the code to), and thus i have had to change it to Firstname1.

Any ideas why this is happening? Is there a problem with access and bugs?

Kind regards
DGI
Microsoft Access

Avatar of undefined
Last Comment
Jeffrey Coachman

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Jeffrey Coachman

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Jeffrey Coachman

Also, make sure the DB is in a "Trusted Location".
...and for code on Reports, make sure the Report is opened in Print Preview explicitly, in order to run any code on any format events
dgi001

ASKER
Hi Jeff

Thanks for this. You have just confirmed what i experienced on 2 occasions where i had to rebuild the form from scratch. I will have to build the code from scratch to avoid this in the future.
Jeffrey Coachman

Perhaps not, oddly enough, sometimes copying Code, Controls, Forms, Modules, ...etc from database to database works fine, ...sometimes not.

I am sure there is some universal root cause for this, but again, if you compile/Compact regularly, this should not happen often...
;-)

Jeff
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck