Solved

Access accdbs and one MDA and same subroutine names

Posted on 2013-01-25
4
390 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
ID: 38819111
<<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
ID: 38819123
<<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
ID: 38819133
<<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
ID: 38825842
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

730 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