jwcolby
jwcolby at colbyconsulting.com
Mon Jul 23 13:18:24 CDT 2007
>Now calling InitializeFromBuffer ... or any other public method I try to add to a Form object ... from outside that Form's own class ... results in an "Application-defined or object-defined error". You don't say how you are calling the form's method. You have to specify the form object, then the method so... Forms("MyForm").InitializeFromBuffer SomeParam Alternatively: Dim frm as form set frm=forms("MyForm") frm.InitializeFromBuffer SomeParam Remember that a form's code is a class and you have to get a pointer to that class in order to call a method of the class. John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Christopher Jeris Sent: Monday, July 23, 2007 1:51 PM To: accessd at databaseadvisors.com Subject: [AccessD] Can't call methods I've added to a form? -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm trying to build a set of forms according to MVC principles, and I think there's something fundamental I don't understand about Access form objects. Everything here is unbound forms, in Access 2002 sp3. I need to have "forms" that serve the same application role but present different user interfaces according to context, so I build a Controller object that creates different Form (view) objects depending on the context. But the Controller needs to tell the view to update itself in certain ways, so I have a method in the form's class like Public Sub InitializeFromBuffer(buffer As DataModelObject) and then the controller's process for opening up the form goes something like Set Me.activeForm = OpenFormByContext(intendedFormClass As String, _ context As ContextInfo) If Not Me.activeForm Is Nothing Then ' it worked Set Me.activeForm.Controller = Me Me.activeForm.InitializeFromBuffer theBuffer ' FAILURE End If Now calling InitializeFromBuffer ... or any other public method I try to add to a Form object ... from outside that Form's own class ... results in an "Application-defined or object-defined error". Is it really not possible to add methods to a Form that get called from outside the Form -- or am I missing something obvious ? I suppose, since adding _properties_ seems to work okay, one kludgy workaround would be to give the Form a property that is its "view proxy object", which is a user-defined class where all the methods I want to add are located, and call methods through the view proxy object ... but I'd rather say what I mean. thanks, Chris Jeris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGpOp35ICCNV0oGWARAiGDAJ9DwZIZ+eo3V/MsLOxBaT2/Y5wzwACgmb4+ j5Xtsy7ZmlM6bOkXXzOS3QY= =rjCB -----END PGP SIGNATURE----- -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com