Share via

Inheritance

Anonymous
2010-09-28T15:04:33+00:00

Is it possible to have/use inheritance with MS Access? 

Scenario:  I use MySQL as my back end.  I use MS Access 2k as my front end.  With that, 15 schemes. Each scheme with 10 or more tables.  One is the CompanyInfo scheme.  We recently when thru a name change, (don't ask, government).  I have in all my reports a Company Header, hard coded, meaning with the label boxes and everything, pictures, lines, borders, etc.....  Just recently I have been making a separate report for the header and just inserting it as a sub-report.  Is there a way to have one front end with a report and have that report sub-reported to another front end?

Office 2000/XP

Windows 2000/XP

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2010-09-28T16:02:31+00:00

You can add another database as "Reference" to your database, which will expose Forms and Reports (in addition to VBA code in modules), and classes from this "r_database", but while you can refer to these classes (forms and reports) in you code of your "f_database", you won't be able to create any object defined in r while in f.

It is like DAO.Recordset. You just can't :

     Dim  x  As  NEW  Dao.Recordset

neither

    Dim x As Dao.Recordset :  Set x = NEW Dao.Recordset

It is rooted in COM. Access-VBA only allows you to define "Public-Not Creatable" in addition to "Private", class instances.

So, f cannot create an r object.

But like CurrentDb can create a DAO.Recordset for you, in the same manner, r can creates object, for you, and then, you are able to use it in f.

So, you will need a method, in a standard module, of r, which creates and return the required object, like:

==== code in r_database ====

Public Function MakeMeSomeClassInRObject( ) AS SomeClassInR

    Set MakeSomeClassInR = new SomeClassInR

End Function

=======================

And NOW, in f, you can use code like:

==== code in f_database ====

Dim toto AS r_database.SomeClassInR

   Set toto = r_database.MakeMeSomeCallInRObject( )

======================

And what you do with the object, define in r, but used in f, is up to you. Note that like CurrentDb.OpenRecordset, the public function that creates the object for you can accept argument to deliver a FULLY INITIALIZED object.  In fact, it is a way to be sure that your code always works with a fully intialized object (or with your object set to Nothing) rahter than having to deal with object 'in the progress' of being usable.

Now, for form and report used as sub form/ sub report, I think that this will imply to add the object to an existing form/report, open in design view, by your code (like wizards do), and sincerely, I am not sure if that worths the trouble... not sure at all. But if you really want to explore the possibility, ... you can. And good luck.

Was this answer helpful?

0 comments No comments

Answer accepted by question author

Anonymous
2010-09-28T15:20:25+00:00

Is it possible to have/use inheritance with MS Access? 

Scenario:  I use MySQL as my back end.  I use MS Access 2k as my front end.  With that, 15 schemes. Each scheme with 10 or more tables.  One is the CompanyInfo scheme.  We recently when thru a name change, (don't ask, government).  I have in all my reports a Company Header, hard coded, meaning with the label boxes and everything, pictures, lines, borders, etc.....  Just recently I have been making a separate report for the header and just inserting it as a sub-report.  Is there a way to have one front end with a report and have that report sub-reported to another front end? 

 

 

I don't believe there's any way for a subreport control to reference a report object in another database.  If I were you, I would look at making the subreport object data-driven, so that it configures itself (including any labels, pictures, etc.) at load time according configuration data it reads from a table.  The configuration table could be in the back-end, so it would automatically be appropriate to whichever back-end you connect to, or it could be in the front-end with a field in each record that identifies which scheme these configuration instructions apply to.


Dirk Goldgar, MS Access MVP

Access tips: www.datagnostics.com/tips.html

Was this answer helpful?

0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2010-09-29T04:50:01+00:00

    MartinezJR wrote:

    I do have the report data driven, I just did not want to have to import the report into all the front ends(20+) because I am trying to lower the size of the front ends.  The smallest being 2mb but the largest being almost 200mb.

    FE 200 mb in size?  When was the last time you did a decompile?     Do you have lots

    of graphics in the FE?

    Decompile or how to reduce Microsoft Access MDB/MDE size and decrease start-up times

    http://www.granite.ab.ca/access/decompile.htm

    Tony

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2010-09-28T21:57:15+00:00

    That is what I was thinking.  Alot of code that I do not know how to write.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2010-09-28T21:56:43+00:00

    I do have the report data driven, I just did not want to have to import the report into all the front ends(20+) because I am trying to lower the size of the front ends.  The smallest being 2mb but the largest being almost 200mb.

    Was this answer helpful?

    0 comments No comments