|
-
Jun 22nd, 2008, 11:57 AM
#1
Thread Starter
Fanatic Member
[Access/VBA] Implements Interface
Hi all. I am intersted in the idea of the "interface" object. I am new but learning, and the ways in which the implementation of the interface object might be put to productive use are dancing just outside my grasp (In other words, I ALMOST get it, and it is driving me nuts!).
I think this might bear directly on a solution in a database application I am working on, but I could use a few examples. I have found some here in the forum, but I think I am missing something. The "ideal" cases in which this object might be the best solution would be helpful. Preferably in more concrete terms than I have found so far. Most explanations I have found either oversimplify to the point where it is hard to understand the purpose of using the interface, or are so abstract that it is difficult to understand the application of the tool to some of my more mundane problems.
Any help would be much appreciated!
-
Jun 23rd, 2008, 05:12 AM
#2
Re: [Access/VBA] Implements Interface
What sre you trying to do?
Is an interface object a class that wraps around something else?
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jun 23rd, 2008, 08:39 AM
#3
Thread Starter
Fanatic Member
Re: [Access/VBA] Implements Interface
My understanding of Interface is that it is essentially a class which contains what amounts to an emtpy code skeleton, and publicly-declared property variables in the declarations section.
From what I have been able to find, the idea is that it provides a consistent means of accessing the same set of properties and procedures within a number of different classes, which may use them in different ways.
I am trying to develop a model in which I have (oversimplification) one main-form which can host MANY subforms, most(but not all) of which share exactly the same design, but utilize different types of data and need to manage it in different ways.
While there are ways I can think of to make this work, I feel like if my understanding of the Interface we complete, it might be part of my answer. I don't have any sensible code samples to post. I haven't been able to get the concept all the way figured out yet. Access' help provides an example which seems to give part of the idea, but not all of it (either that or I still need to ponder . . .)
The basics are like this:
(Class module named ISfmDetailMASTER)
Code:
Public frmParent As Form
Public SfmController As Form 'A form module which will be loaded to provide the functionality need by the master subform
Public Sub DoSomething(ByVal SomeParameter As SomeType)
'Empty
End Sub
Public Sub Do SomethingElse(ByVal SomeOtherParameter As SomeType)
'Empty
End Sub
I may or may not have set that up correctly, but now:
(Code in the "Master" subform)
Code:
(Declarations)
Implements IsSfmDetailMaster
'From here, the object properties list in the VBE provides a listing
'for IsSfmDetailMaster in the left drop down, with Property
'Get/Let settings 'and procedures in the righthand dropdown:
'***************************************************
'Property Settings
'***************************************************
Public Property Get IsSfmDetailMaster_frmParent() As Form
End Property
Public Property Let IsSfmDetailMaster_frmParent(ByVal HCS As Form)
'Now fill this in with code
End Property
Public Property Get IsSfmDetailMaster_frmParent() As Form
'Now fill this in with code
End Property
Public Property Let IsSfmDetailMaster_sfmController(ByVal HCS As Form)
'Now fill this in with code
End Property
'***************************************************
'Methods
'***************************************************
Public Sub IsSfmDetailMaster_DOSomething(ByVal SomeParameter As SomeType)
'Now fill this in with code
End Sub
Public Sub Do IsSfmDetailMaster_SomethingElse(ByVal SomeOtherParameter As SomeType)
'Now fill this in with code
End Sub
Now, here is where I get lost. The next step (I think?) is to set up a class module (or even use another form module as a class, which can then be loaded by a string reference to it's name . . .) which somehow uses this interface to mesh with the MASTER form. Do I Declare a type ISfmDetailMaster in the class(or form) module, and set it to reference the first form??
Or should I have done that in the first (master) form, and "implemented" the interface in the "slave" module or form, which is only going to provide procedures and functionality?
I know how to do this by "delegation":
Load the main form, then instance the class I want to use for functionality and access the properties and procedures.
But somehow, I am obsessed with this "Interface" thing. I don't think they would have made it if it didn't have some sort of application . . .
Sorry for the long-winded post. I have found I can't explain what I am looking for very well until I know how to use the code. My problem here is conceptual I think, and another forum user warned my about not using concrete code examples. Hard to do, though, when I don't know how to use it!!
Any insight would be VERY much appreciated!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|