G
Hello all -
I am using Access 2002, and I was trying to find out if there's a way
to gain access to the query names through intellisense in a VBA window.
For example, say I was to do...
DoCmd.OpenQuery "001_truncate_items"
The .OpenQuery method of the DoCmd object doesn't display a nice
intellisense/drop down list of the query objects currently in the
database -- you must type the query name as a string.
The above example I one situation I think most people can identify with
where the development environment is lacking.
What I want to do...is to create an
object/collection/enum/class/whatever that will iterate through the
QueryDefs collection (I'm assuming this would be my starting point),
populate some type of object, and then I can instantiate the object,
and voila...magically get the query object names in intellisense!
Who knows if this is even possible in the VBA/Access world, but I see
many benefits of this type of approach, especially after working a
while in the .NET/OOP/C# world for a while.
I started with something like the following to get started:
(I had this code in a Class object named HelperMethods)
Public Function GetQueryNames() As Collection
Dim qdf As DAO.QueryDef ' instance of QueryDef collection
Dim qdfCol As Collection ' temporarily hold query name collection
' iterate through qdf collection to grab names
For Each qdf In CurrentDb.QueryDefs
qdfCol.Add qdf.Name ' add query name to collection
Next qdf
Set qdf = Nothing
Set GetQueryNames = qdfCol ' return collection
End Function
Then, in a procedure, I did something like:
Private Sub cmdProcess_Click()
Dim ohelper As HelperMethods
Dim oQry As New Collection
Set oQry = ohelper.GetQueryNames()
End Sub
But then realized I couldn't get what I want. I want to be able to type
oQry, hit the dot, and then I get my list of query names (or whatever
else I decide to populate the object with).
I thought about trying to use Property Get in a class, but then I'd
have to hardcode a property for each object name -- NOT what I want to
do...I want to try to do this dynamically w/o maintaining some Property
list. I can use an Enum too to get the same effect, but that'd still be
a list I'd have to maintain manually.
It might be tough to do this since the compiler will have to know about
whatever is supposed to be populated in particular object before it
runs, and how can you do that in design (compile) time?
Maybe someone has a cool idea how to piece things together to achieve
what I want.
Any suggestions on how to accomplish this are greatly appreciated!
Kael
I am using Access 2002, and I was trying to find out if there's a way
to gain access to the query names through intellisense in a VBA window.
For example, say I was to do...
DoCmd.OpenQuery "001_truncate_items"
The .OpenQuery method of the DoCmd object doesn't display a nice
intellisense/drop down list of the query objects currently in the
database -- you must type the query name as a string.
The above example I one situation I think most people can identify with
where the development environment is lacking.
What I want to do...is to create an
object/collection/enum/class/whatever that will iterate through the
QueryDefs collection (I'm assuming this would be my starting point),
populate some type of object, and then I can instantiate the object,
and voila...magically get the query object names in intellisense!
Who knows if this is even possible in the VBA/Access world, but I see
many benefits of this type of approach, especially after working a
while in the .NET/OOP/C# world for a while.
I started with something like the following to get started:
(I had this code in a Class object named HelperMethods)
Public Function GetQueryNames() As Collection
Dim qdf As DAO.QueryDef ' instance of QueryDef collection
Dim qdfCol As Collection ' temporarily hold query name collection
' iterate through qdf collection to grab names
For Each qdf In CurrentDb.QueryDefs
qdfCol.Add qdf.Name ' add query name to collection
Next qdf
Set qdf = Nothing
Set GetQueryNames = qdfCol ' return collection
End Function
Then, in a procedure, I did something like:
Private Sub cmdProcess_Click()
Dim ohelper As HelperMethods
Dim oQry As New Collection
Set oQry = ohelper.GetQueryNames()
End Sub
But then realized I couldn't get what I want. I want to be able to type
oQry, hit the dot, and then I get my list of query names (or whatever
else I decide to populate the object with).
I thought about trying to use Property Get in a class, but then I'd
have to hardcode a property for each object name -- NOT what I want to
do...I want to try to do this dynamically w/o maintaining some Property
list. I can use an Enum too to get the same effect, but that'd still be
a list I'd have to maintain manually.
It might be tough to do this since the compiler will have to know about
whatever is supposed to be populated in particular object before it
runs, and how can you do that in design (compile) time?
Maybe someone has a cool idea how to piece things together to achieve
what I want.
Any suggestions on how to accomplish this are greatly appreciated!
Kael