473,396 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Addin calling function in Parent

Dear All,

I have an MDB file (Access 2000/XP) which contains generic routines I
use in various apps (eg, API calls, File access classes etc).

I have compiled into an MDE file which I reference in VBA from my other
Access applications.

This works fine and I'm quite happy with it... except for one area;
error handling. In most of my functions I call an error handler which
stores the details of the error into a table so that I can review the
error log in future. What I would like is for my ADDIN to call the
error function stored in the CALLING application so that any errors
that occur in the addin are recorded and actioned as per the error
handler of the calling function... is this possible? If I try to refer
to a generic error handler (eg HandleError(errmsg, err) from the ADDIN,
ofcourse the compiler complains this function doesn't exist because it
doesn't know that I'm using this MDE as an addin in future... if I add
a REFERENCE to my calling app, then that means that ADDIN will only
work for that app !?

In case thats not very clear heres an example of what I'm attempting;

Calling app: Main.MDB
function test()
call testaddin()
end function

function HandleError(ErrMsg as string, Err as integer)
' Code to save error in local table etc..
' ....
end function

Addin App: ADDIN.MDE
function testaddin()
on error goto handleerror

dim a as integer

a = 0/0

errexit:
exit function

handleerror:
HandleError("Error Occurred", err)
resume errexit
end function

- results in a compile error as Handle Error is not known in the
ADDIN.mde....
If this isn't possible, am I perhaps trying to achieve this in the
wrong way and there is a better option/idea??

Many thanks,

Ju Chao

Nov 13 '05 #1
6 3290
jc******@hotmail.com wrote:
Dear All,

I have an MDB file (Access 2000/XP) which contains generic routines I
use in various apps (eg, API calls, File access classes etc).

I have compiled into an MDE file which I reference in VBA from my other
Access applications.

function HandleError(ErrMsg as string, Err as integer)
' Code to save error in local table etc..
' ....
end function


What happens if you put HandleError in each MDB/MDE?
Nov 13 '05 #2
Salad <oi*@vinegar.com> wrote in message news:<Mc*****************@newsread1.news.pas.earth link.net>...
jc******@hotmail.com wrote:
[SNIP]


What happens if you put HandleError in each MDB/MDE?


Well, it will compile but then my generic MDE would be hard coded to
work with only 1 particular HandleError routine...

This is an issue because, for example, if:
1. DB 1 saves errors in d:\db\dberr.mdb
2. DB 2 only displays errors
3. DB 3 saves errors in d:\db3\dberr.mdb

My Generic MDE file should call the Calling Apps HandleError routine
and so perform the appropriate function when an error occurs.

Regards

Ju Chao
Nov 13 '05 #3
Ju Chao wrote:
Salad <oi*@vinegar.com> wrote in message news:<Mc*****************@newsread1.news.pas.earth link.net>...
jc******@hotmail.com wrote:

[SNIP]


What happens if you put HandleError in each MDB/MDE?

Well, it will compile but then my generic MDE would be hard coded to
work with only 1 particular HandleError routine...

This is an issue because, for example, if:
1. DB 1 saves errors in d:\db\dberr.mdb
2. DB 2 only displays errors
3. DB 3 saves errors in d:\db3\dberr.mdb

My Generic MDE file should call the Calling Apps HandleError routine
and so perform the appropriate function when an error occurs.

Regards

Ju Chao


I added a reference to Northwind. I then opened Northwind and attempted
to create a reference to the main app. It would not do that, and it
complained of a circular reference.

So I tried something else. This concept may do what you want. You'll
need to modify it to your needs.

In DB1, I created the following routines in Module1. I also created a
reference to Northwind.

Sub Junk()
JunkExternal
MsgBox "I'm back again"
End Sub

Public Sub JunkMain()
MsgBox "Hello from Main Module"
End Sub
I opened Northwind and then added the following routines.
Public Sub JunkExternal()
MsgBox "Hello From Module Northwind"
RunAccessSub
End Sub

Public Sub RunAccessSub()
Set appAccess = CreateObject("Access.Application.8")
appAccess.OpenCurrentDatabase "C:\Test\db1.mdb", False

'Run proc in DB1
appAccess.Run "JunkMain"

appAccess.Quit
Set appAccess = Nothing
End Sub

I'd be curious to hear back if this concept works for you.

Nov 13 '05 #4
Salad <oi*@vinegar.com> wrote in message news:<Zssad.13

I added a reference to Northwind. I then opened Northwind and attempted
to create a reference to the main app. It would not do that, and it
complained of a circular reference.

So I tried something else. This concept may do what you want. You'll
need to modify it to your needs.

In DB1, I created the following routines in Module1. I also created a
reference to Northwind.

Sub Junk()
JunkExternal
MsgBox "I'm back again"
End Sub

Public Sub JunkMain()
MsgBox "Hello from Main Module"
End Sub
I opened Northwind and then added the following routines.
Public Sub JunkExternal()
MsgBox "Hello From Module Northwind"
RunAccessSub
End Sub

Public Sub RunAccessSub()
Set appAccess = CreateObject("Access.Application.8")
appAccess.OpenCurrentDatabase "C:\Test\db1.mdb", False

'Run proc in DB1
appAccess.Run "JunkMain"

appAccess.Quit
Set appAccess = Nothing
End Sub

I'd be curious to hear back if this concept works for you.


I understand what you are doing and that would work. The only issue(s)
I have with that approach are:
1. The second module (Northwind in your case) is hardcoded to call the
parent app. It should determine the calling app itself.
2. It would be quite slow; what you are doing is opening a second
instance of Access to run the sub... it would be ideal to just call
the current instance of the parent app from within the addin as it is
already in memory.

Hmmm.. has to be a solution here somewhere.

Thanks for your continuing ideas.

Ju Chao
Nov 13 '05 #5
Ju Chao wrote:
Salad <oi*@vinegar.com> wrote in message news:<Zssad.13
I added a reference to Northwind. I then opened Northwind and attempted
to create a reference to the main app. It would not do that, and it
complained of a circular reference.

So I tried something else. This concept may do what you want. You'll
need to modify it to your needs.

In DB1, I created the following routines in Module1. I also created a
reference to Northwind.

Sub Junk()
JunkExternal
MsgBox "I'm back again"
End Sub

Public Sub JunkMain()
MsgBox "Hello from Main Module"
End Sub
I opened Northwind and then added the following routines.
Public Sub JunkExternal()
MsgBox "Hello From Module Northwind"
RunAccessSub
End Sub

Public Sub RunAccessSub()
Set appAccess = CreateObject("Access.Application.8")
appAccess.OpenCurrentDatabase "C:\Test\db1.mdb", False

'Run proc in DB1
appAccess.Run "JunkMain"

appAccess.Quit
Set appAccess = Nothing
End Sub

I'd be curious to hear back if this concept works for you.

I understand what you are doing and that would work. The only issue(s)
I have with that approach are:
1. The second module (Northwind in your case) is hardcoded to call the
parent app. It should determine the calling app itself.


Yes. You would need to change the functions so you would pass the
calling database name.
2. It would be quite slow; what you are doing is opening a second
instance of Access to run the sub... it would be ideal to just call
the current instance of the parent app from within the addin as it is
already in memory.
Are you planning on lots of errors? :-).

I'm not sure how to do it. I think Michka would be the best person to
answer the question. If he were to step in, you'd get a definitive answer.

Hmmm.. has to be a solution here somewhere.

Thanks for your continuing ideas.

Maybe start another post/thread, and use Michka in the subject line.
Maybe he'd spot it and answer it.
Ju Chao

Nov 13 '05 #6
Salad <oi*@vinegar.com> wrote in message news:<7d****************@newsread1.news.pas.earthl ink.net>...
Ju Chao wrote:
I understand what you are doing and that would work. The only issue(s)
I have with that approach are:
1. The second module (Northwind in your case) is hardcoded to call the
parent app. It should determine the calling app itself.


Yes. You would need to change the functions so you would pass the
calling database name.
2. It would be quite slow; what you are doing is opening a second
instance of Access to run the sub... it would be ideal to just call
the current instance of the parent app from within the addin as it is
already in memory.


Are you planning on lots of errors? :-).

I'm not sure how to do it. I think Michka would be the best person to
answer the question. If he were to step in, you'd get a definitive answer.

Hmmm.. has to be a solution here somewhere.

Thanks for your continuing ideas.


Maybe start another post/thread, and use Michka in the subject line.
Maybe he'd spot it and answer it.


I wonder if Michka does a search for "Michka" on the news groups? In
which case, maybe this will come up on his search:

Michka Michka Michka Michka Michka Michka Michka Michka Michka Michka

:-)

I'll start a new post.

Thanks Salad.

Ju Chao
Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Jaime Rios | last post by:
Hi, I created a COM AddIn for Word that performs the functions that it needs to, but I needed to add the ability for the toolbar created by the COM AddIn to remember it's last position and...
3
by: scott | last post by:
hi all, hope some one can help me. Ill try and explain what im trying to do as best i can. i have a parent class that has a vertual function, lets call it virtual int A(). That vertual function...
2
by: anthonyberet | last post by:
This is the first time I have tried out functions (is that the main way of making subroutines in Python?) Anyway, my function, mutate, below #make a child string by randomly changing one...
6
by: jalkadir | last post by:
Let's say that I have this class: class Parent{ private: char* str; public: const char* getStr(){return str;} }; And then I create a child class class Child{ private: std::string str;...
6
by: Jon Hyland | last post by:
Ok, I'm a little rusty on this, it should be a simple problem but I can't figure it out. How can I handle form events in my main code page?? I'm creating a Windows App in C#. Rather than make...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
0
by: guilligan.geo | last post by:
Hello, I'm trying to create an addin for Outlook 2002 using the one provided in the demo of win32com as a starting point. I've been able to do my addin and test it if I go the "standard" way...
0
by: sandhya | last post by:
Iam facing a peculiar issue when i try to reference a .net dll within a .net Excel Addin dll created through Extensibility projects. Whenever i try to create the object of the class in the...
6
by: Christof Nordiek | last post by:
Hi, I created an Addin Project with the Addin-Project-Wizzard in VS2005. I added some code from a Knowledge Base How To und built the project. It worked, and the Addin got registered with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.