p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Access VBA (http://p2p.wrox.com/forumdisplay.php?f=80)
-   -   Check/Reconnect Missing References (http://p2p.wrox.com/showthread.php?t=25744)

ErikTheProgrammer February 18th, 2005 09:34 AM

Check/Reconnect Missing References
 
Hello,
I have an Access MDE app that I refresh & post to a website monthly (terribly inefficient, I know).

Recently a demo of the app blew up because of a missing reference; specifically, MS DAO 3.6...

My question: Is it possible to check for a missing reference, and if necessary, to reconnnect it at runtime, from an MDE?

Thanks in advance!

rjweers February 20th, 2005 11:16 AM

You can fix the problem. But the fix is for the operating system your MDE is running on, not for your MDE. This is because the MDE is compiled and references are fixed (unchangeable).

To make the reference work, you must get the library that you're using registered to the operating system. Michael Kaplan has an article about this at http://www.trigeminal.com/usenet/usenet026.asp?1033

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org

Bob Bedell February 20th, 2005 02:22 PM

Hi Eric,

I've been playing around with Terry Kreft's open source Reference Wizard for a bit since you posted, and notice that the article Randall posted contains a link to it too. I think it might work for you.

The link for the reference wizard is at http://www.mvps.org/access/modules/mdl0022.htm.

I've been able to use it to repair a broken reference to the DAO library in a 2K2 database. Here's how I went about it.

1. The Reference Wizard is a MDA library in A97 format. So I first converted it to A2K2 format, then created an MDB in A2K2 format to host the MDA.

2. The first thing you want to do is convert the MDA to an MDE. Otherwise you won't be able to convert the host MDB to an MDE after setting a reference to the converted MDA.

Before you convert the Wizard to an MDE, however, add a new standard module to it named "basOpenForm". Add this code to the standard module:

Sub OpenForm(frmName As String)
    DoCmd.OpenForm frmName, , , , , acDialog
End Sub

This will allow you to open forms in the MDA by calling them from MDB code. The form in the Wizard you are interested in is named "wzfrm_USysRefInfo". This form uses a callback function to populate a list box with the references set in the host MDB application. If any references .IsBroken property returns True, the broken reference will be listed and flagged in the list box. "wzfrm_USysRefInfo" includes two command buttons that enable you to Repair the broken references and Refresh the references by reading/creating registry keys. Once you have basOpenForm added to the MDA, recompile it to be sure you don't have compilation errors that would prevent an MDE from being created, then create the MDE version of the Wizard.

3. After you get the Reference Wizard converted to an MDE, open your host MDB's VBA editor and set a reference to the MDE version of the Reference Wizard (just as you would set a reference to any other class library). Create a new form in the host MDB that will enable you to invoke "wzfrm_USysRefInfo" from a command button. Add the following code in the command buttons OnClick event:

Private Sub Command0_Click()
    Call OpenForm("wzfrm_USysRefInfo")
End Sub

This routine calls into the referenced MDE version of the Wizard and loads "wzfrm_USysRefInfo" in the host MDB.

4. Once the MDB is working OK with the MDE version of the Wizard, create a MDE version of the host MDB application.

At this point you should be good to go. Of course, the only method I had available to test reparing the broken DAO reference was to physically move the dao360.dll from the C:\Program Files\Common Files\Microsoft Shared\DAO folder, open the app, check to see that the broken reference was listed (it was), place the DAO dll back in its shared folder, and click the Repair button on wzfrm_USysRefInfo (the reference to DAO was repaired correctly).

So there you have it if you feel like playing around with an MDA for a bit and distributing it with your MDE app.

HTH,

Bob


Bob Bedell February 20th, 2005 02:47 PM

And just to clean up my little blunders:

I wrote:

"The first thing you want to do is convert the MDA to an MDE. Otherwise you won't be able to convert the host MDB to an MDE after setting a reference to the converted MDA."

Should read:

"The first thing you want to do is convert the MDA to an MDE. Otherwise you won't be able to convert the host MDB to an MDE after setting a reference to the unconverted MDA."

Bob




All times are GMT -4. The time now is 05:56 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.