I'm not certain this can be done so I'm posting the question to see if anyone can respond with a possible solution. Since describing what I want to do is somewhat confusing I'll try to define it with an example.
Here is what I want my code to look like when using the Helper Class:
Assuming the current database has a table named Employees and there are 3 records in the table, the result of this code block would be:
There are 3 records in Employees.
Assuming there is another table in the database, one called Sales for example, I could also have written clsHelper.Tables.Sales.RecordCount to determine how many records were in the Sales table.
Once I get an idea of how to set up this scenerio, I plan on extending the features and usage of this class for things a little bit more useful.
So that being said, the helper class needs to extract the user defined tables in the current database through class methods. I know I can create this functionality by creating a Employees or Sales class with a RecordCount method but I don't want to do that. I want to know if this can be done dynamically? The reason for this is to be able to use the helper class in any database and have it do what it's coded to do.
There isn't any specific reason I have to do this other than to see if it can be done. Any help or leads would be greatly appreciated so I can put this personal bug of mine to rest.
Thanks.
Here is what I want my code to look like when using the Helper Class:
Code:
Dim clsHelper As clsHelperClass
public sub ShowMeStuff
Set clsHelper = new clsHelperClass
debug.print "There are " & clsHelper.Tables.Employees.RecordCount & " records in " & clsHelper.Tables.Employees.Name & "."
set clsHelper = nothing
End Sub
Assuming the current database has a table named Employees and there are 3 records in the table, the result of this code block would be:
There are 3 records in Employees.
Assuming there is another table in the database, one called Sales for example, I could also have written clsHelper.Tables.Sales.RecordCount to determine how many records were in the Sales table.
Once I get an idea of how to set up this scenerio, I plan on extending the features and usage of this class for things a little bit more useful.
So that being said, the helper class needs to extract the user defined tables in the current database through class methods. I know I can create this functionality by creating a Employees or Sales class with a RecordCount method but I don't want to do that. I want to know if this can be done dynamically? The reason for this is to be able to use the helper class in any database and have it do what it's coded to do.
There isn't any specific reason I have to do this other than to see if it can be done. Any help or leads would be greatly appreciated so I can put this personal bug of mine to rest.
Thanks.