[AccessD] Any limits on what can be passed as an argument?

Kenneth Ismert kismert at gmail.com
Mon Mar 11 21:18:26 CDT 2013


> Arthur Fuller
> <vba>
> Dim qd as QueryDef
> Dim qd1 as QueryDef
> Set qd = QueryDefs("myDef")
> Set qd1 = qd
> ... make some changes to qd, such as changing the sql property
> </vba>
>

Arthur,

Going by your example, you have three references to the query:  qd = qd1 =
QueryDefs("myDef")

You can test this by calling ObjPtr() for each reference.

You can't create or destroy myDef by creating or destroying qd or qd1.  The
permanent reference in the QueryDefs collection prevents such manipulations.

Since the query is global, do this:

<vba>
With QueryDefs("myDef")
    ... make your changes
End With
</vba>

This has exactly the same effect as your example, but is much clearer and
simpler.

Pass the name as your argument.

-Ken


More information about the AccessD mailing list