Link to home
Start Free TrialLog in
Avatar of Bernard Thouin
Bernard ThouinFlag for Switzerland

asked on

Access accdbs and one MDA and same subroutine names

Hi

I have two Access 2007 applications which are using a common set of subroutines and functions in an MDA. Now, one of the 2 Access apps needs a slight variation of one of the routines in the MDA. I was hoping I would have a kind of "function overloading" by defining, in that one Access app a slightly different version of the routine of the MDA but with the same routine name, and that, at run-time, Access would first look in the app itself before calling the routine in the MDA. But it doesn't. It ignores the version in the app, and runs the version in the MDA (and strange enough it doesn't complain about having 2 routines with the same name, one in the app, one in the MDA).

Is there anyway I can force Access to first look in the app and run that routine instead of the one in the MDA ? Or do I have to bite the bullet and have 2 different routine names and call the one I need specifically ?

I must add that the call to the routine is done from the MDA, so maybe that's why it doesn't look outside of the MDA ?

So, to be clear:

AppA and AppB both use a common MDA.
AppA calls a large routine R1 in MDA.
R1 calls a further routine R2 which is now existing in the MDA AND in AppA.
When AppA is calling R1 in the MDA, and R1 is calling R2, I'd like it to call AppA.R2 and and not MDA.R2

Wishful thinking ?

Thanks for help.
Bernard
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

<<Is there anyway I can force Access to first look in the app and run that routine instead of the one in the MDA ? >>

 Try a fully qualified reference, which is:

<VBA project name>.<procedure name>

 You can find your VBA project name under tools/properties in the VBA editor window.

Jim.
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<<But it doesn't. It ignores the version in the app, and runs the version in the MDA (and strange enough it doesn't complain about having 2 routines with the same name, one in the app, one in the MDA).>>

  Keep in mind that the VBA project names differ, so interally the fully qualified reference is not the same.

  What's weird is why it's not calling the one in the main project first; how are you calling the procedure?

Jim.
Avatar of Bernard Thouin

ASKER

Hi JDettman

Thanks for your multiple answers.

>>Try a fully qualified reference<<
I tried, but it didn't work, so I abandoned the idea, although my syntax (project name) might not have ben completely correct.

>> I can't think of anyway to call the procedure in the main DB from the lib only if it's there<<
OK, that's exactly what I wanted to know.

>>why it's not calling the one in the main project first<<
Probably because I'm calling the routine in the main DB from the Lib (mda)

>>how are you calling the procedure?<<
Just using its name: Call <procedure name>. It then of course finds that procedure in the Lib (as the call is in the Lib) and executes that.

I have now given up using fancy stuff, did 2 different procedures (stored in the Lib) for the 2 use cases, and call the one or the other depending on a flag which tells me which app is really calling the Lib. That's not ideal, but it of course works fine.

Thanks for your help.
Bernard