With pre-declare true you test code needs no define.
Sub testImplementClass()
With cSomething.Create(5, "Quack")
Debug.Print .Bar
End With
End Sub
With a single class, interface makes little sense but multiple classes implementing the same interface allow you to some interesting...
I think you missed a step in the tutorial. To add the attribute, you must export the class module to a text file, then open it in a text editor like Notepad, add the attribute text. then import the text file back into your database. The attribute creates an instance of the class when you FE runs...
In cISomethingFactory you define get properties for Bar and Ducky which are not needed, you can comment them out.
in cSomething you are retuning the wrong type.
'Private Property Get cISomething_Ducky() As Long
Private Property Get cISomething_Ducky() As String
cISomething_Ducky = Ducky
End...
Since you defined the interface class "cISomething", shouldn't the implementation functions have that name.
Private Property Get cISomething_Bar() As Long
ISomething_Bar = Bar
End Property
Private Property Get cISomething_Ducky() As Long
ISomething_Ducky = Ducky
End Property
IMO
The...
Constants are converted to literal values before execution so don't exist for eval to calculate.
Const One as Long = 1
Const Two as Long = 2
If myValue = ONE + TWO then
is converted to
If myValue = 3 then
I have looked at your sample DB, VERY IMPRESIVE. The 2 samples I supplied were to more simply show both recursive and non-recursive methods that are easer to follow.
The Northwind sample was based on my production contact form which I developed before your sample. Most users click the search...
What he said.
Anytime you use recursion, add a level counter or something to detect infinite loops. Look at your data for errors in child/parent links.
I previously posted sample databases using tree controls.
Multi-value field (MVF) using tree control - fills the tree using recursion, it's easy to follow in the debugger because of the limited data. See TreeFillAvailable function in Form_MVF_Control_Tree form.
This 2nd attached ACCDB works...
For a generic lookup the class will still work, you will need to provide more information.
With AnyTableClass
.QueryToOpen = "Your Named Query"
.ParmName = "Your ID lookup Parameter"
.LookupID = YourKeyValue
Description = nz(.ColumnFromRS(1))
Location = nz(.ColumnFromRS(2))
End With
Option...
I agree this would be over kill for one off lookup of a single column. The OP indicated repeated lookups for multiple columns and the possibility of keeping a recordset open to do it. Assuming this is part of a single function call, initiating the class once and using it repeatedly for each...
Simpler and faster then a bunch of dLookups.
Option Compare Database
Option Explicit
' Sample Class to search recordset and return values
Private Type MyTableType
qd As DAO.QueryDef
rs As DAO.Recordset
End Type
Private This As MyTableType
Private Sub Class_Initialize()
' Do...
Any server backend support by Access will work, but may be slower than a "Access" BE depending on how the FE was coded i.e. opening a form linked to a table without a filter. The corruption issue on WAN is only with an "Access" BE.
If you are filling variables from table columns like the following
Description = MyTableDesc(LookUpID)
Location= MyTableLocation(LookUpID)
..
SomeOtherField = MyTableSomeOtherField(LookUpID)
Consider using a class to fill and return values from your query.
With New MyTableClass
.LookupID =...