Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

conditional object libary reference

Status
Not open for further replies.

dpimental

Programmer
Jul 23, 2002
535
US
All, I have a set of databases on a network that several users access.
Some access them from their local machine and some on a remote server. The problem is the remote server has ms office 2010 and the local machines have ms office 2007.

I need to reference the Microsoft Access Object Library; but I use the remote server, so it is the 14.0 object library, which the local machines don't have. They have the 12.0 object library.

So, how do I conditionally set which object library to load based on the version the user has access to?

David Pimental
(US, Oh)
 
Either use late binding or develop with the oldest Library.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I'm not sure that I could use late binding.
I would have to change a whole lot of code to do that.

If I have office 2010, which would have the Microsoft Access 14.0 Object Library, If I developed on a access version of 2007 (which uses the 12.0 object library), wouldn't the process break when I tried to use it on my machine?



David Pimental
(US, Oh)
 
There is an automatic UPWARD conversion of references.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I started doing the development in office 2010, how do I make the reference valid for office 2007?

Do I just recompile the code in an access 2007 database?

David

David Pimental
(US, Oh)
 
Do I just recompile the code in an access 2007 database
Yes, but you have to set the correct references before compiling.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
If I've done as you suggest and then go back to my office 2010 machine and update / add vba code, do I have to recompile it on a office 2007 machine?

David Pimental
(US, Oh)
 
Of course yes.
But, as I've already said, develop with your OLDEST version in order to avoid reference issues.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
dpimental : I was in a similar predicament a few years back, when we had people on office 2003 / 2007 & 2010.

These forums as PHV suggests recommended late bindings, OK yes it was a bit of a pain removing all references to Office and then updating all the code where I was explicitly declaring variables of a particular Office data type, we have five different Access applications varying in size and it took a couple of days to refactor then all, but it was the best thing I did.

I develop in my 2010 environment and each time I roll out the runtime version I don't worry or care what office the user may have installed.

Some users even have Office 2013 now, but the Access applications have just continued to work without any issues and I'm hoping that will be the case when the next version of Office is released.

The last thing you want to have to do is compile various Access versions for varying Office versions and manage deployment to the right users with the right Office.

Not sure how big your app is or how many users you have, but the benefits I have gained by refactoring to late bindings has far out weighed the time it took to convert the code!

1DMF


"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
1DMF, PHV, thanks for your comments. I certainly appreciate them. I need to investigate further, as I have been developing some time in access 2010 and have only recently seen some problems with users of access 2010.

The first problem came when a user of access 2007 was implanting the following code snippet.
Code:
 DoCmd.RunCommand acCmdRefresh

The last time it happened, I was just opening a form with standard vba code?

Another thing that I noticed that I thought was the issue is the "Microsoft Accesss 14.0 / 12.0 Object Library" in the tools/references of the module menu.

If you have access 2007, it's 12.0.
If you have access 2010, it's 14.0.

I thought that was the issue I was seeing. I had developed in 2010, so access 2007 users would throw an error, since they don't have object library 14.0.

Even a empty database with a empty module checks the proper object library and won't let you uncheck it?

So, does that mean that I have to develop in access 2007 or get the users on 2007 to upgrade to 2010?

David Pimental
(US, Oh)
 
Ah you are having issues with the version of access everyone is running under.

You'll save yourself a load of money switching to using Access Runtime!

Then you won't have to buy Access or the Office with Access (Pro) and only need users to have Home & Business version (unless they require Publisher / Access).

What I do is develop in Access 2010, ensure everyone has Access 2010 Runtime installed and rollout an ACCDR version of the app when it changes.

ACCDR is basically an ACCDE compiled version with the 'E' then changed to 'R'.

So everyone runs an Access 2010 runtime version of the app and then I use late bindings in the app so it doesn't matter what version of Word / Excel / Outlook is installed!

The Access Runtime is free, so there is no cost involved using it and you save well over £100.00 per user not having to by Office with Access anymore, plus eliminate the headache of having various versions of Access to contend with!

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
Actually, I work for a pretty big company. They don't waste money; but if they did, they could waste a lot of it. I don't think it would be too difficult to get everyone on the same version.

But, that is the problem, correct.
Everyone needs to be on the same version that I develop in, correct?
So that the object library is the same?

David Pimental
(US, Oh)
 
Everyone needs to have the same version of any references.

So if you hard code (select a specific reference), then that must be present on everyone's machine using your app.

I just had a similar issue when playing with the mscorlib.dll , the version available on my machine is .NET4 , some users only had .Net 2/3/3.5 , and so the misbehaved on their machines.

I had to install .NET4 on their machine for the DB to work properly again.

If you bind your app to a specific library, then that library needs to be available.

Another thing to remember is Access 2010 has new controls not available in previous versions, if you use them, then you won't even be able to open the source code in a lower version of Access and neither will your apps run on versions of Access without these controls.

That's why the Runtime is so great, everyone is running the same app in the same environment with the same libraries as you are developing under.

Well it works for me :)

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top