Solved

Access accdbs and one MDA and same subroutine names

Posted on 2013-01-25
4
355 Views
Last Modified: 2013-01-27
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
Comment
Question by:bthouin
  • 3
4 Comments
 
LVL 57

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
<<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
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 300 total points
Comment Utility
<<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
 
LVL 57

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
<<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
 
LVL 1

Author Comment

by:bthouin
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now