Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I share classses across multiple access DB applications?

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Hi,

I seem unable to work out how I can have a repository for shared classes across multiple access DB's so I don't have duplicate code in multiple applications.

Where do i put what and how do I link it so that the compiled ACCDR contains all the required code including shared code from the library of classes?

Thanks,
1DMF

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Free Dance Music Downloads
 
You may have done this part already:

Build your "library" database. In the library database rename the Project to something unique like "LibraryProject". UseTools menu, choose VBA Project Properties, and then change the name. Ensure that each class module instancing is set to 2 PublicNotCreateable not Private. On the class select properties. Now the problem is that you will be able to declare a variable of your class but you cannot create an instance. So in the library you need to create a function for each class to return an new instance.
Example

Public Function GetMyClass() As MyClass
Set GetMyClass = New MyClass
End Function

For the databases using the library you have to set a reference to the library databases. Use the browse in the refernce menu. Then in your databases you can use the library.


Public mc As LibraryProject.MyClass
Set mc = LibraryProject.GetMyClass()


I have not worked with the runtime developer enough to know the next step. I doubt it packages both databases as a single ACCDR, so I think you have to distribute your accdr with the with the library database maybe as an accde.
 
Thanks Maj, I'll have a go and let you know how I get on.

It's a shame if you have to provide the library as a separate ACCDE/ACCDR , Also won't that break the referencing?

If I have the reference to a folder / ACCDB where I develop (source code), but the actual app will be running locally on their C:Drive, I don't want them all referencing and linking to the source code folder, I want them to use their own local version!

Also why do you have to set them to 'public not creatable' and use a factory to create instances of the class?

That would require a rewrite of all application to take advantage of any shared library?

hmm, I like the DRY ethos, but Access doesn't make it easy does it!

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Free Dance Music Downloads
 
It's a shame if you have to provide the library as a separate ACCDE/ACCDR , Also won't that break the referencing?
I have not played with the runtime, but I am pretty sure that is the way you would have to do it. Hopefully someone who has experience can chime in. But I would think that you deliver the library with the runtime package. Then have the code to set the reference to the proper folder or provide them a file picker to set the reference.

Also why do you have to set them to 'public not creatable' and use a factory to create instances of the class?
This is just an unfortunate limit to VBA. If you want something more robust, you may want to consider doing your front end in visual studio. VB.net is really really nice to work with.
 
Didn't we have this conversation already
Thread181-1630893
 
Hi Maj,

Didn't we have this conversation already
Yes we did, and I got no further with it!

As the other thread is closed I thought I would reserect the question, as I am developing a new app and had the need to duplicate exisiting code, it prompted me to evalute the need for a class library that could be shared once again.

Though I am now looking at a T-SQL solution, instead of using UDF's in Access queries, which is where the duplciated code was needed.

This is just an unfortunate limit to VBA. If you want something more robust, you may want to consider doing your front end in visual studio. VB.net is really really nice to work with.

Yeah, this could be why I got no further the last time, looking into it and the logistics of refactoring everything to run from a library let alone the compiling and rolling out issues, I think I need to consider bitting the bullet and migrating to full VB.NET.

Can I get a free version of VB Studio IDE?

I know I used one for my OU course but that was under educational circumstances, not commercial ones, do I have to convince my boss to purchase VB Studio before I can start porting over to VB.NET?



"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Free Dance Music Downloads
 
Visual Studio Express 2012 is completely free along with SQL Server express. At a minimum download it to play with. You can do things with that you could never do in Access. It just amazes me that you can get a development environment like this for free. The learning curve is a little steep. I would get a good book on ADO.NET if going that route. I have been building front ends in vb.net and using access as the back end. There just are not the limitations you have in VBA, if you can think it up you can code it. It sounds like you have a good OOP background, so you will definately enjoy working in .net.
I am a hobbyist only, but I would think express would work for the scale of development you are doing.
 
Thanks Maj,

Well I've downloaded the ISO, burnt to DVD and am currently installing.

Is ADO.NET the best data access object to use?

My biggest concern is moving away from bound form controls and handling the .NET disconnected model.

How I go about handle DB updates and record locking etc..

This is all done by Access currently , where's a good place to start?

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Free Dance Music Downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top