[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 408
  • Last Modified:

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
0
bthouin
Asked:
bthouin
  • 3
1 Solution
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
<<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.
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
<<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 ?>>

 Think so.  The reference will need to be specific.  I can't think of anyway to call the procedure in the main DB from the lib only if it's there, which is what your thinking of in terms of overloading.

Jim.
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
<<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.
0
 
bthouinAuthor Commented:
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
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now