By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,940 Members | 611 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,940 IT Pros & Developers. It's quick & easy.

Passing data between 2 seperate projects

P: 16
I have built a quote engine for the rating of insurance premiums. Each month the rates that generate the premiums change which requires a new database file be created with updated premium tables (we need to keep the old ones so we can quote premiums for different months rates). I use the following dynamic reference to access the relevant rating file dependant upon the user's selection:

Access.References.AddFromFile "G:\UW Manual\Generic Testpack\Rates\" & strYear & "\" & strMonth & "\" & strProductName & ".mdb"

This works fine and I am able to call a sub in the rating file named "PrivateCarRatesGen". What I need to do is have this procedure populate containers / arrays / vars within the original project file.

Any ideas how I would go about this?




A couple of ideas I've been thinking about:

1. Remove the dynamic reference and simply open the file:

Dim RatesApp As Access.Application
Set RatesApp = New Access.Application
RatesApp.OpenAccessProject ("G:\UW Manual\Generic Testpack\Rates\2009\March\Trade-Marque+.mdb")
RatesApp.Run("PrivateVarRatesGen")

But how would the sub return values to the original project?

2. Write data to a text file / table. This would be functional but I am loathed to go about it this way.


To clarify: 2 project files. The 1st calls a sub in the 2nd. The 2nd needs to populate vars / containers and use classes in the 1st.
Feb 24 '09 #1
Share this Question
Share on Google+
7 Replies


FishVal
Expert 2.5K+
P: 2,653
There was something you could use at the end of this thread.
Feb 24 '09 #2

P: 16
How would I access a container in the calling mdb from the child mdb? Something like:

appParentApp.Modules("ModuleNameHere").ContainerNa meHere ?

One other question; can I not create a class rather than a form to pass the parent mdb through? Using a reference to create an instance of the class in the child mdb like the following:

Application.References.AddFromFile "C:\MyPath\MyChildMDBHere"
Dim AppChild as New ConnectionClass
AppChild.ParentApp = CurrentProject.Application?

This brings a debug due to incorrect use of the New keyword which seems odd (I set the class to Public in the child mdb and have established the reference prior to creating the instance of the class in the parent).

Thanks for your help thus far :)
Feb 25 '09 #3

FishVal
Expert 2.5K+
P: 2,653
@Nates
It should work if Modules("ModuleNameHere").ContainerNameHere returns ContainerNameHere object in parent application.

One other question; can I not create a class rather than a form to pass the parent mdb through?
I think it is possible. You will need to instantiate this object of this class as global variable.

Using a reference to create an instance of the class in the child mdb like the following:

Application.References.AddFromFile "C:\MyPath\MyChildMDBHere"
Dim AppChild as New ConnectionClass
AppChild.ParentApp = CurrentProject.Application?

This brings a debug due to incorrect use of the New keyword which seems odd (I set the class to Public in the child mdb and have established the reference prior to creating the instance of the class in the parent).

Thanks for your help thus far :)
Since AppChild is being instantiated in parent mdb I don't see how it could be used in child mdb.
As for error with "New". Did you try to instantiate it this way in child mdb?
Feb 25 '09 #4

P: 16
Not sure I can make use of the solution you linked.

I need to do the following:

1. Midway through a sub in project 1 a call is made to a sub in project 2
2. The called sub in project 2 generates endorsements / excesses / premiums using a class in project 1 (not through creating a new instance of said class, rather using the one already active within project 1).
3. Project 2 returns the generated endorsements / excesses / premiums to containers / vars in project 1.
4. Project 1 resumes on the next line of the sub after the call to project 2.

Effectively I need the sub within project 2 to behave as if it was a sub within a module in project 1.

Does VBA support C style includes perhaps?
Feb 25 '09 #5

FishVal
Expert 2.5K+
P: 2,653
@Nates
Is the sub in project 2 needed to be executed in context of project 2 ? E.g. it uses data stored in project 2 to generate output.
Feb 25 '09 #6

P: 16
The sub in project 2 needs to make use of data within both project 1 and 2 to return data to project 1.
Feb 26 '09 #7

FishVal
Expert 2.5K+
P: 2,653
Well.

Here is a simple example.
Attached Files
File Type: zip 2 projects interaction.zip (35.7 KB, 148 views)
Feb 26 '09 #8

Post your reply

Sign in to post your reply or Sign up for a free account.