The amazing disappearing VBA code

A

AccessVandal via AccessMonster.com

In the Access Option, make sure you remove the “Compact On Close†and
“Compile On Demandâ€. If these are enabled, they can cause corruption and the
problems you posted here.

You might also want to disabled the “Perform Name AutoCorrect†at the same
time.

http://allenbrowne.com/bug-03.html

http://allenbrowne.com/ser-47.html

Still, why use drive mappings when they are lots of posting on these problems
in the past 5 years?
 
C

Chuck

We do disable the "Compact On Close" and the "Perform Name AutoCorrect"
options, however, I have to check on the "Compile On Demand". As far as
drive mapping problems over the last five years, how do you avoid it when
you have over a 1000 people on an installation that need files across a
network?
 
J

John W. Vinson

As far as
drive mapping problems over the last five years, how do you avoid it when
you have over a 1000 people on an installation that need files across a
network?

Use the stable and reliable \\server\path\filename syntax for linked tables
(and other network accesses) rather than assuming that the K: drive reliably
points to it.
 
A

AccessVandal via AccessMonster.com

Yes, as John puts it. Use link tables....

Sometimes the OS changes the drive designation or the changes are by the
users themselves, they can simply slot a flash drive, compact flash device or
just simply slot in and boot up windows and the OS will automatically assign
the drive letter on it own and this might have replace the Mapped drive
letter.
 
A

Avril H

Nope, I have examples of the code disappearing where I have the "Compact on
close" turned on, and where it is turned off. Makes no difference. If
anything, it seems more stable with the switch turned on.
 
T

Tony Toews [MVP]

AccessVandal via AccessMonster.com said:
Still, why use drive mappings when they are lots of posting on these problems
in the past 5 years?

What? I'm unaware of any problems with drive mappings these past 5
years. Could you explain more?

Now if you are talking drive mappings vs UNC paths that's an argument
with 7 reasons on one side and 5 reasons on the other side.

Tony
 
D

David W. Fenton

Now if you are talking drive mappings vs UNC paths that's an
argument with 7 reasons on one side and 5 reasons on the other
side.

I have to pull a bunch of Word files out of OLE link fields for a
new client. The links are stored as UNC paths even though the users
all have mapped drives.

It makes perfect sense that the OLE link path would be resolved to
UNC, because that's the only way you can guarantee that the document
will be openable by everyone. The design makes perfect sense to me,
since different machines might have different drive mappings.
Obviously, a well-run IT shop will have the same logon scripts and
drive mappings for everyone, but I think it's better not to assume
that.

I stopped using mapped drives in 1998.
 
C

Chuck

In our case, the computers are made to a specific standard, each having the
same configuration as the next. It is against policy to use any other
storage media besides what is already installed. The mapping script is
executed at NETLOGON time so everyone gets a drive mapped with the letter
"G" and the letter "H". There is also a shared drive for personal use with
a letter "Y". There is even one with an "X" for secured storage of
documents. This mapping has been this way for over 10 years now and we
never had any conflicts. Not every user is computer saavy and will know how
to map drives on their own or even know what a UNC is and how to enter into
an explorer window.

I have tried both ways to link tables together and both have worked as
designed. Although the situation of the VBA code being deleted sounds rare,
based upon several postings, it does indeed happen. And from our standpoint
at work, it is related to the attempt of opening the database prior to the
mapping script being completed. Since users are now using a script to check
for the existence of the mapped drives and then executes Access to open the
database, we have not had any problems. I don't think this is 100%
foolproof.
 
D

David W. Fenton

Not every user is computer saavy and will know how
to map drives on their own or even know what a UNC is and how to
enter into an explorer window.

That's because you've been providing them with mapped drives!

I provide support and Access programming to small businesses. My
first Access client to get an NT server was back in 1998. I knew
about networking already from working in a few other environments,
and knew how UNC worked. I was not originally their server admin,
but I was responsible for all their workstations. I set them up with
appropriate shortcuts on the desktop and trained them how to
navigate Network Neighborhood (this was pre-Windows 2000, which
introduced "My Network Places"). They had not difficulty navigating
this way at all.

But, one important thing:

When they got the server, we sat down and had several meetings to
design the structure of how data would be stored on the file server
and what user groups and security levels would be implemented. The
key is to have a a half dozen distince top-level shares, rather than
sharing the root of a data folder on the server. It's much easier to
get to your data if you have, say Administrative, UserData,
PublicData, ClientData, and so forth as your top-level shares,
instead of having to navigate to the root of drive and then drill
down to those folders.

Now, the organization of the data on the file server's hard drive
was completely different than what was presented to the users. The
key point is that you organize the hard drive for security, backup
and system administration purposes, and then design your shares to
reflect user needs for access.

Most shops I've been in have taken no care at all in designing the
shares presented to the users. There's also the problem of Windows
Server presenting a whole bunch of visible shares that are not for
end users (such as Exchange and so forth). That problem has
increased since the days of NT 4 Server, so it does make things
harder in terms of the top-level server view being crowded with a
bunch of shares that are not of interest to the end users.

The key point was that we organized the server and shares to reflect
the way the users wanted to have their work organized, and then
trained them on how to use UNC paths and how to navigate the server
and its shares in Windows Explorer. After only a few weeks, the
users all understood the system and had no difficulties whatsoever.

And we didn't have to worry about maintaining any logon scripts.
I have tried both ways to link tables together and both have
worked as designed. Although the situation of the VBA code being
deleted sounds rare, based upon several postings, it does indeed
happen. And from our standpoint at work, it is related to the
attempt of opening the database prior to the mapping script being
completed. Since users are now using a script to check for the
existence of the mapped drives and then executes Access to open
the database, we have not had any problems. I don't think this is
100% foolproof.

That sounds to me like a network configuration error. The logon
script that maps the drives should be executing long before the
users have any possibility of loading any applications. At least, in
all the environments I've worked in (which is pretty extensive now,
more than 10 years after my first heavy-duty Windows networking
experience), the logon scripts run before the desktop even populates
with its shortcuts. And they run just after the TaskBar and start
menu button appear, but before the start menu actually responds to
mouse clicks.

Something sounds odd there to me.

But, at least you've come up with a solution. I can't quite figure
out *why* it would be the solution, but the longer I'm in this
business the more I realize that the systems we work with are so
complex that more and more I am willing to try "voodoo"
troubleshooting, i.e., doing things that logically don't have any
connection to the problem, but that sometimes solve the problem
anyway.

I'm not yet sacrificing chickens and sprinkling their blood over the
servers, but I'm on track in that direction! ;)
 
A

AccessVandal via AccessMonster.com

Hi Tony,

I’m surprised that you’re not aware of drive mapping problems but then again
it’s not an Access problem.

If you do a google search on “Mapped Drive disappearing†you’ll see lots of
posts regarding these problems.

I had mapped drives problem since the days of Windows 95 and Windows 98.
There’s a lot of improvement to the OS since but I’m not sure the problem was
resolved in XP or Vista. I do still see numerous posts on these problems.

Back than, even a basic office setup without servers, the mapped drives does
not work all the time. You’ll have to create a logon script to make sure that
the mapped drives are connected correctly to the drive letter as what the OP
had done.

There’s too many mapped drive problems to be listed here. Could be memory,
BIOS, mainboard IRQ, software like Anti-Virus, FireWall…etc.

As far as I know, mapped drive letters are automatically assigned by the OS
and on a first come first serve basis. If you do not have a script to delete
the mapped drive, the next time the OS reboots, the mapped drive letter might
not be the same or mapped to the wrong share folder.
 
T

Tony Toews [MVP]

David W. Fenton said:
It makes perfect sense that the OLE link path would be resolved to
UNC, because that's the only way you can guarantee that the document
will be openable by everyone.

Until the IT department changes the name of the server. That's one of
the five reasons. <smile>

Tony
 
T

Tony Toews [MVP]

AccessVandal via AccessMonster.com said:
Back than, even a basic office setup without servers, the mapped drives does
not work all the time. You’ll have to create a logon script to make sure that
the mapped drives are connected correctly to the drive letter as what the OP
had done.

Sure, that's standard stuff when it comes to drive letters as far as
I'm concerned.
There’s too many mapped drive problems to be listed here. Could be memory,
BIOS, mainboard IRQ, software like Anti-Virus, FireWall…etc.

Umm, well not so sure about the above reasons. Although someone
attaching a multi card reader to USB adapter can add a bunch of drive
letters in a few seconds.
As far as I know, mapped drive letters are automatically assigned by the OS
and on a first come first serve basis. If you do not have a script to delete
the mapped drive, the next time the OS reboots, the mapped drive letter might
not be the same or mapped to the wrong share folder.

Sure but the script should be taking care of all those things for you.

Tony
 
A

AccessVandal via AccessMonster.com

Umm, well not so sure about the above reasons. Although someone attaching a multi card reader >to USB adapter can add a bunch of drive letters in a few seconds.

And not forgetting the fact that user can change the mapped drive letters too,
in a few seconds. I have seen users do that out of curiosity or after they
came back from an OS classes.
Sure but the script should be taking care of all those things for you.

The trick works, but not always. Network Hardware can fail the mapped drive
but with UNC, it did not fail. The network hardwares may need to be reset to
simply get back the mapped drives. I know because I have done this many times.
A hardware compatibility issue comes to mind. Protocols between Routers, Hub,
Switchers and NIC, sometimes these have compatibility issues that can cause
the mapped drives to disappear or a temporary disconnection.
Sure, that's standard stuff when it comes to drive letters as far as
I'm concerned.

It would be great if users were more aware of the problems of mapped drive in
the first place before deploying.

With that knowledge, we can reduce the numbers of chickens being slaughtered
by the Voodoo consultants and we will never need David W. Fenton join the
Voodoo club and hopefully he doesn’t need to replicate those dead chickens
there and get banned again. :)

Tony Toews [MVP] wrote:
 
D

David W. Fenton

Until the IT department changes the name of the server. That's
one of the five reasons. <smile>

But that doesn't happen very often,

And if it does, you can override it in the HOSTS file, i.e., mapping
the new IP address to the old name, which will be used instead of
asking your local DNS or WINS server to resolve the name to an IP
address.
 
T

Tony Toews [MVP]

David W. Fenton said:
But that doesn't happen very often,

And if it does, you can override it in the HOSTS file, i.e., mapping
the new IP address to the old name, which will be used instead of
asking your local DNS or WINS server to resolve the name to an IP
address.

Which means distributing the new HOSTS file. <shudder>

Tony
 
D

David W. Fenton

Which means distributing the new HOSTS file. <shudder>

Any IT infrastructure I'm in charge of replaces a server with a new
server of the exact same name. That means it has to be done outside
regular office hours, for something that elaborate, usually on a
weekend.

Mapped drives are ridiculous. They've been outdated forever.

But changing server names is just something that oughtn't happen,
ever.
 
D

David W. Fenton

Which means distributing the new HOSTS file. <shudder>

I could also be done with DNS entries from your network's local DNS
server (yes, I know that's redundant). You just point two server
names to the same IP address.

There really isn't any reason to map drives.
 
W

wendell

Until the IT department changes the name of the server.  That's one of
the five reasons.  <smile>

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages -http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog -http://msmvps.com/blogs/access/
Granite Fleet Managerhttp://www.granitefleet.com/

And I've just been through that - it turned out we needed to keep both
servers online for an extended period after we installed a new server
- ugly all the way around.

And to get back to the topic at hand, I've just seen the problem the
original poster raised - on a complex Access front-end with lots of
VBA - and yes it is split, and deployed to each workstation - but this
happens to be the development copy! I'm hopeful that I have a good
backup from last night, but I can't restore it until tomorrow as the
server is some 800 miles from me and unattended outside normal working
hours. The environment is Windows Server 2008 with Access 2007 SP2.

I've heard others report this problem, but have not experienced it
myself until tonight. Something appears to be going on, and I see
several recent reports of it on other forums.

Wendell
 
A

AccessVandal via AccessMonster.com

Thank you. Hope that you can keep us informed of your results.

My testing In Windows Vista SP1 with Access 2007 SP1, if you have a missing
reference of a dll or ocx that’s not registered the computer it is possible
that you will loose the module codes. Access will prompt a message asking
whether to continue to open the Form with the “Yes†and “No†buttons. If you
click “Yesâ€, you’ll not loose the codes, but if you click “No†you’ll loose
the code and the database file will be corrupted.

The results are not conclusive, as the problem does not appear all the time.
 
C

Chuck

Just making another comment about the disappearing VBA code since I am the
original poster.

It continues to happen in our environment and it does indeed happen when
someone attempts to open the MDB or ACCDB file prior to the network drives
being mapped. We have tested this over and over and it occurs every time.
I just don't understand if you open a shortcut on your desktop to a MDB or
ACCDB file on a network drive and it isn't mapped yet, how the heck does
Access start and not return a file not found error. I've test this several
times and it attempts to open the database. Once that happens, the code is
corrupted.

We cannot split the database and put a front end on each desktop. No matter
what argument you have here in the group about that being the correct way,
as a military organization, that will not happen. I have tried to split the
database and still put the backend on a different drive, but it still the
VBA code gets deleted if the user opens the file prior to a complete map.

We have added a small script that will check for the existence of the map
drive and they are always the same assigned letters. The ability to
disconnect and re-map drives are disabled for the users in policies. No one
can add any hardware or put in USB drives because it will not be
recogonized. It is indeed a very tight sytem for the end user.

If the user runs the script, we have no problems with the code.
Unfortunately, I cannot stop someone from making a shortcut to the files.

I think at this point it is realized that the problem occurs, it is now a
matter whether or not Microsoft will look into it and see what the problem
is or how to prevent code from disappearing.

Thanks to everyone who made suggestions here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top