By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,356 Members | 2,752 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,356 IT Pros & Developers. It's quick & easy.

Code Issues

P: n/a
Hi

Sometimes when i edit previously saved VBA code e.g. To update field
names etc the revised code does not work.
Even if i copy and paste in a previous version it does not work.

The only solution seems to be to delete the existing code, re-type ir
word for word and hey presto it works.

Of course you might think typo or something but its like Access seems
to totally ignore the code.

This may sound daft but its like Access seems to have a memory of
previously typed code and it seems to be remember the earlier code and
does not 'want' to process the new stuff.....

Am i imagining this or is there something I need to do?

I created stacks of functions a few months ago. Some of the field
names have changed and I updated both the query and the function for
the new code. Access rejected it. My only solution was to delete that
module and re-key the code again.

Any suggestions

chris

Nov 13 '05 #1
Share this Question
Share on Google+
13 Replies


P: n/a
There has, in the past, been a problem with form code ceasing to work -- it
was there, but it just didn't execute. But that error happened even if the
most recent changes had not been to the code that stopped working. There was
much speculation as to why, but no definitive answer.

No one has reported it as being either consistent or frequent, and I haven't
heard of it happening with Access 2002 or 2003. You did not say what version
of Access you are using, so I wouldn't speculate if this is what you have
experienced.

Some have had luck using "save as text" to save the form's module and then
"load from text" in similar situations.
Sorry I can't be of any real help.

Larry Linson
Micosoft Access MVP
"AFKAFB" <ch***********@rbos.com> wrote in message
news:11********************@z14g2000cwz.googlegrou ps.com...
Hi

Sometimes when i edit previously saved VBA code e.g. To update field
names etc the revised code does not work.
Even if i copy and paste in a previous version it does not work.

The only solution seems to be to delete the existing code, re-type ir
word for word and hey presto it works.

Of course you might think typo or something but its like Access seems
to totally ignore the code.

This may sound daft but its like Access seems to have a memory of
previously typed code and it seems to be remember the earlier code and
does not 'want' to process the new stuff.....

Am i imagining this or is there something I need to do?

I created stacks of functions a few months ago. Some of the field
names have changed and I updated both the query and the function for
the new code. Access rejected it. My only solution was to delete that
module and re-key the code again.

Any suggestions

chris

Nov 13 '05 #2

P: n/a
AFKAFB wrote:
Hi

Sometimes when i edit previously saved VBA code e.g. To update field
names etc the revised code does not work.
Even if i copy and paste in a previous version it does not work.

The only solution seems to be to delete the existing code, re-type ir
word for word and hey presto it works.

Of course you might think typo or something but its like Access seems
to totally ignore the code.

This may sound daft but its like Access seems to have a memory of
previously typed code and it seems to be remember the earlier code and
does not 'want' to process the new stuff.....

Am i imagining this or is there something I need to do?

I created stacks of functions a few months ago. Some of the field
names have changed and I updated both the query and the function for
the new code. Access rejected it. My only solution was to delete that
module and re-key the code again.

Any suggestions

chris

Perhaps this is a time when decompile might assist. Open the app with a
/decompile. EIther that or create a blank database and import all
objects as well as menus and imp/exp specs. Mayber there is something
that is in the system tables that needs to be corrected. THen rename to
new database to your app's mdb.
Nov 13 '05 #3

P: n/a
Salad
This is the first time i've heard of a decompile
Can you explain in a bit more detail how this works and how i start the
DB wih a /decompile.
regards
chris

Nov 13 '05 #4

P: n/a
On 21 Aug 2005 13:52:52 -0700, "AFKAFB" <ch***********@rbos.com>
wrote:

Create a shortcut on your desktop that points to:
<path_to>msaccess.exe <path_to>your.mdb /decompile

-Tom.

Salad
This is the first time i've heard of a decompile
Can you explain in a bit more detail how this works and how i start the
DB wih a /decompile.
regards
chris


Nov 13 '05 #5

P: n/a
Tom
Can you please let me know in more detail what a decompile will do
chris

Nov 13 '05 #6

P: n/a
Good idea to be cautious: while decompiling is a powerful tool, it's also
capable of causing problems.

Take a look at what MichKa has to say about decompiling at
http://www.trigeminal.com/usenet/usenet004.asp

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"AFKAFB" <ch***********@rbos.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Tom
Can you please let me know in more detail what a decompile will do
chris

Nov 13 '05 #7

P: n/a
Br
AFKAFB <ch***********@rbos.com> wrote:
Hi

Sometimes when i edit previously saved VBA code e.g. To update field
names etc the revised code does not work.
Even if i copy and paste in a previous version it does not work.

The only solution seems to be to delete the existing code, re-type ir
word for word and hey presto it works.

Of course you might think typo or something but its like Access seems
to totally ignore the code.

This may sound daft but its like Access seems to have a memory of
previously typed code and it seems to be remember the earlier code and
does not 'want' to process the new stuff.....

Am i imagining this or is there something I need to do?

I created stacks of functions a few months ago. Some of the field
names have changed and I updated both the query and the function for
the new code. Access rejected it. My only solution was to delete
that module and re-key the code again.

Any suggestions

chris


Have you tried saving the form under a different name, delete the old
one and rename the new one?

Do you have AutoNameCorrect turned on? Try turning it off.

Access holds two versions of the code. The script and the compiled code.
Sounds like the compiled version isn't being updated properly?

The /decompile command line option may help (eg.MSAccess.exe my.mdb
/decompile), or create a blank DB and import all your objects into it.
Could be a corrupted database. (Backup first obviously)
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #8

P: n/a
Bradley
You've said something which has sparked a thought.
When i use the Performance Analyser the first comment is that the
Application has not been saved in a compiled state. Is this any help?

To answer your questions - i've done as suggested re changing and
deleting the form - no effect.

Why would AutoCorrect affect this ? It happens to be switched on at
the moment.

I assume the script code is the version i've created and the compiled
code reads from this and stores it elsewhere. Where can you view the
compiled code?

I created a shortcut as suggested - it read something like "C:\MS
Office\1033\Access.exe" "r:\location\application.mdb/decompile"

where location was the drive name

Access came back with a message it could not find my DB :
"r:\location\application.mdb/decompile.mdb"

But i never typed "decompile.mdb" - any ideas??

I think my DB is corrupt - as it does things it should not do whereas
other queries etc are fine - it has me stumped.

Unfortunately i'm not sure how far back the corruption goes and whilst
i have loads of back up copies i cannot be certain how far back i've
been corrupted...

help

chris

Nov 13 '05 #9

P: n/a
"AFKAFB" <ch***********@rbos.com> wrote
Sometimes when i edit previously saved VBA code e.g. To update field
names etc the revised code does not work.

This problem is also sometimes evident when you add a field to an existing
form; the new field name does not show in Intellisense and may not be
recognized by VBA code. Decompile does not fix this.

What has worked for me in every case so far is to remove the form's Record
Source, save the form, and then put the form's Record Source back the way it
was.
--
Darryl Kerkeslager

Power corrupts.
Absolute power corrupts absolutely.
Knowledge is power.
See www.adcritic.com/interactive/view.php?id=5927
Nov 13 '05 #10

P: n/a
AFKAFB wrote:
Why would AutoCorrect affect this ? It happens to be switched on at
the moment.


Auto corrupt is a feature I've been turning off on every new mdb I make
since I began using A2003 and read Allen Browne and others' advice on it.

It may well be a good idea for you to do what Salad suggested and create
a new mdb and make sure autocorrect is turned off. Then use the get
external data to bring the stuff from your current mdb into it.

I'm not sure if a decompile would be necessary after doing this, but I
don't think it will hurt (notwithstanding Doug's caution). I find A2003
creates enormous mdb files and the decompile and then a compact helps me
get things down to a manageable level. I've done some very involved
apps in A97, for example, that never exceeded 5 megs in size. In A2003,
I'm lucky to get anywhere near this size, though the big front enc app
I'm working on presently is the largest I've ever done.

I also second Darryl's advice, I've run into irritating problems like he
describes many times in the versions of Access I've used.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "What's UP, Dittoooooo?" - Ditto
Nov 13 '05 #11

P: n/a
AFKAFB wrote:
Bradley
You've said something which has sparked a thought.
When i use the Performance Analyser the first comment is that the
Application has not been saved in a compiled state. Is this any help?

To answer your questions - i've done as suggested re changing and
deleting the form - no effect.

Why would AutoCorrect affect this ? It happens to be switched on at
the moment.

I assume the script code is the version i've created and the compiled
code reads from this and stores it elsewhere. Where can you view the
compiled code?

I created a shortcut as suggested - it read something like "C:\MS
Office\1033\Access.exe" "r:\location\application.mdb/decompile"

where location was the drive name

Access came back with a message it could not find my DB :
"r:\location\application.mdb/decompile.mdb"

But i never typed "decompile.mdb" - any ideas??
YOu need to insert spaces between switches. Ex: To open the app
exclusive and then decompile. The switches are not contained in quotes.

"C:\MSOffice\Access.exe" "r:\application.mdb" /decompile /excl
I think my DB is corrupt - as it does things it should not do whereas
other queries etc are fine - it has me stumped.

Unfortunately i'm not sure how far back the corruption goes and whilst
i have loads of back up copies i cannot be certain how far back i've
been corrupted...

help

chris

Nov 13 '05 #12

P: n/a
Hi
Bradley noted
"Access holds two versions of the code. The script and the compiled
code.
Sounds like the compiled version isn't being updated properly? "

My question is I assume the script code is the version i've created and
the compiled
code reads from this and stores it elsewhere. Where can you view the
compiled code?

Also how do you re-compile code?

chris

Nov 13 '05 #13

P: n/a
"AFKAFB" <ch***********@rbos.com> wrote in
news:11**********************@f14g2000cwb.googlegr oups.com:
Bradley noted
"Access holds two versions of the code. The script and the
compiled code.
Sounds like the compiled version isn't being updated properly? "

My question is I assume the script code is the version i've
created and the compiled
code reads from this and stores it elsewhere. Where can you view
the compiled code?
You can't, and you're never supposed to be able to.

Read the article my Michael Kaplan that Doug cited
(http://www.trigeminal.com/usenet/usenet004.asp). He explains the
"11 states of compilation" that are involved behind the scenes with
all your VBA code.

You only have access to the canonical code that you type.

Theoretically, when you change the code, the next time it compiles,
it will update the compiled code to reflect the changes in the code
you typed. However, this doesn't always happen, and the result can
be code that doesn't do what you expect, invalid code that doesn't
report compile errors or code-bearing objects that are corrupted and
won't open or cause Access to crash.
Also how do you re-compile code?


On the debug menu, there should be a command for compiling code.
Before Access 2000, you could compile the open modules, or compile
all modules, or compile and save all modules. But with the new
monolithic save model implemented in A2K, that is no longer
possible, and all you have is the choice to compile the whole
project. I add this command button to my code window toolbar,
because it's imortant to force compile code often in A2K.

Also, you should go to the options for code and turn off COMPILE ON
DEMAND. What this does is reduce the number of non-requested
compiles.

But, keep in mind that any code that is called and is not compiled
will be compiled on the fly in an attempt to run it. Code-bearing
objects can open and run in an incompletely compiled state.

If you use any significant amount of code, you should definitely be
compiling your project to make sure you don't have compile errors.

You also want to be sure that all of your modules have OPTION
EXPLICIT as the second line of them (this was not the default in
A2K, in a stupid move to make A2K foolishly consistent with Word and
Excel code modules). There is also an option to set to insure that
all your modules from here on out get created with OPTION EXPLICIT.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.