Trap wrong or missing mde library

  • Thread starter Thread starter Nick Hoare
  • Start date Start date
N

Nick Hoare

I have an mde application that uses another mde as a code library. If
the code library is the wrong version I get On Load errors from the
default form, even though this form uses none of the code library
functions. It looks like the mde is doing a compile check on startup
and if this fails won't run any code. Is there a way to trap this error
and give the user a sensible error message?
 
In general, if a referenced library is not present, this will throw out the
operation of the whole application. I guess your situation is a variation of
that.

It is possible to write code to check for this. However, the code must be
completely "disambiguated". This means that every symbol, without exception,
must be prefixed with the name of the library from which it derives.

Thus:
VBA.Msgbox "Heeee" & Access.vbCrLf & "eeelp!"

not:
Msgbox "Heeee" & vbCrLf & "eeelp!"

and so on.

You could maybe write such code to make a call to a sub in your library. If
the call fails (which you would trap with an On Error Resume), you would
assume that the library was bad or missing. I doubt that you could actually
fix it at that point: you could only issue an error message, & shut down the
application in a controlled manner.

IOW, lots of work, perhaps for not much benefit.

HTH,
TC
 
Thanks TC this is a new idea to me. I have tried this and the problem
seems to be the Startup Form Event Handler. The error is that the On
Load expression is not an VBAProject (blah). Any idea how I can
disambiguate the Event Handler. I have tried setting a user function
instead of [Event Handler] but it will not permit any syntax other than
=Myevent(). I have tried Me.Myevent() or MyForm.MyEvent() but I get
invalid syntax.

Will I have to go with an autoexec macro to run code first rather than a
startup form?

Nick
 
Hi Nick

Just saw your reply.

Do not try to start a form until you have fixed any reference problems.
Instead, have the autoexec macro call a function in a standard module. Have
nothing else in that module, apart from that function. Make that function
disambiguated. Call nothing outside that module, from that function. That
function then checks for errors, fixes them (if possible - otherwise dies
with an error) >then< runs the startup form.

HTH,
TC



Nick Hoare said:
Thanks TC this is a new idea to me. I have tried this and the problem
seems to be the Startup Form Event Handler. The error is that the On
Load expression is not an VBAProject (blah). Any idea how I can
disambiguate the Event Handler. I have tried setting a user function
instead of [Event Handler] but it will not permit any syntax other than
=Myevent(). I have tried Me.Myevent() or MyForm.MyEvent() but I get
invalid syntax.

Will I have to go with an autoexec macro to run code first rather than a
startup form?

Nick

In general, if a referenced library is not present, this will throw out the
operation of the whole application. I guess your situation is a variation of
that.

It is possible to write code to check for this. However, the code must be
completely "disambiguated". This means that every symbol, without exception,
must be prefixed with the name of the library from which it derives.

Thus:
VBA.Msgbox "Heeee" & Access.vbCrLf & "eeelp!"

not:
Msgbox "Heeee" & vbCrLf & "eeelp!"

and so on.

You could maybe write such code to make a call to a sub in your library. If
the call fails (which you would trap with an On Error Resume), you would
assume that the library was bad or missing. I doubt that you could actually
fix it at that point: you could only issue an error message, & shut down the
application in a controlled manner.

IOW, lots of work, perhaps for not much benefit.

HTH,
TC
 
Back
Top