Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740

    Unanswered: remote library of class modules

    i have a bunch of class modules - they work fine, but so far i have been importing my class modules in every application (which is a pain).

    now i'm going for a single library of classes. following Mehta's proposal i take the same classes that work fine when imported into my app, switch them to PublicNotCreatable, make the ClassProvider module & functions, and finally reference my library of classes in the main apps.

    Mehta wants me to use this, but it (and a thousand variations on it) produce compile errors despite most variations making sense to intellisense.
    Dim myMail As izyClass.izyMailClass
    Set myMail = izyClass.izyMail
    MsgBox myMail.Info
    Set myMail = Nothing

    where the class library holding izyMailClass is referenced
    izyMail is the function in the provider module izyClass that returns the new instance of izyMailClass

    but this much simpler construct works:
    Dim myMail As izyMailClass
    Set myMail = izyMail
    MsgBox myMail.Info
    Set myMail = Nothing

    Mehta's original is Excel and mine is Access. is this just a little wrinkle between E.VBA & A.VBA or is there a problem somewhere?

    thanks for any observations.

    izy
    currently using SS 2008R2

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    IzyMail SHOULD be a public function that constructs a new instance of your mail class for you. What is in in reality?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    hi Teddy,

    it is in reality one of several public functions in a normal (not class) class-provider module.

    Public Function izyMail() As izyMailClass
    Set izyMail = New izyMailClass
    End Function

    it all seems to work perfectly when called from another .MDx with e.g.
    Private Sub butTestInfo_Click()
    Dim myMail As izyMailClass
    Set myMail = izyMail
    MsgBox myMail.Info
    Set myMail = Nothing
    End Sub

    all the public subs and properties of the classes work 100%, prompting for their parameters, executing their duties, returning properties etc.

    i am more than happy that the simpler code works...
    ...unless my failure with Mehta's code is indicative of some underlying problem that i don't understand and that is going to bite me in the bum sometime later.



    putting the question another way: do you use simple code like the above or do you use the "more-complicated" Mehta style?
    and if Mehta-like: why?



    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi Izy

    one hasn't gone to the bother of reading your link and so is approaching this thread from the traditional position of ignorance but...

    doesn't the error lie with the line:
    Code:
     Dim myMail As izyClass.izyMailClass
    based on
    Quote Originally Posted by izyrider
    izyMail is the function in the provider module izyClass that returns the new instance of izyMailClass
    i.e. izyClass is the module that returns an instanatiated izyMailClass object - it has nothing to do with the class per se, non?

    I will read the link though promise....
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Yeah - just read.

    Looks to me like it isn't totally clear in the example - I will test my observations but...
    The qualifer for the Class should be the name of the db containing your code (in the example from MSDN ClassProvider). The qualifier for the function that returns the instantiated object is the name of the module (unspecified in the example but izyClass in your code).
    Testimonial:
    pootle flump
    ur codings are working excelent.

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Yup:

    Remote project called RemoteClassCode. Contains Class called clsTheClass and general module called mdlReturnsTheClass.
    Class:
    Code:
    Dim sName As String
    Property Get Name() As String
    	Name = sName
    End Property
    Property Let Name(uName As String)
    	sName = uName
    End Property
    Module:
    Code:
    Public Function New_clsTheClass () As clsTheClass 
    	Set New_clsTheClass  = New clsTheClass 
    End Function
    Calling function in other db:
    Code:
     Sub UseExportedClass_EarlyBinding()
    	Dim anEmployee As RemoteClassCode.clsTheClass
     
    	Set anEmployee = mdlReturnsTheClass.New_clsTheClass 
     
    	anEmployee.Name = "Pootle Flump"
    	MsgBox anEmployee.Name
     
    End Sub
    HTH
    Last edited by pootle flump; 01-13-06 at 11:43. Reason: Mucked up my code - somehow it worked anyway - ho hum.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  7. #7
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    duh!

    well spotted pootle!

    continuing with my faked names:

    Private Sub butTestInfo_Click()
    Dim myMail As izyLibrary.izyMailClass
    Set myMail = izyClass.izyMail
    MsgBox myMail.Info
    Set myMail = Nothing
    End Sub

    compiles without error (and works!).

    thanks a lot

    izy
    currently using SS 2008R2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •