Charlotte Foust
charlotte.foust at gmail.com
Wed Sep 1 13:07:20 CDT 2010
If that is so, then the instructions are somewhat misleading, since the directions I found indicate that when the current object is being exported, you don't need the name. Might be a versional difference. Charlotte Foust On Wed, Sep 1, 2010 at 10:27 AM, Heenan, Lambert <Lambert.Heenan at chartisinsurance.com> wrote: > No you cannot do that. OutputTo requires the name of the object being output. So you would think that this would work... > > > Dim db As Database > Dim qdfTemp As QueryDef > > Set db = fnThisDb > > With db > ' Create temporary QueryDef. > Set qdfTemp = .CreateQueryDef("", _ > "SELECT * FROM SomeTable") > DoCmd.OutputTo acOutputQuery, qdfTemp.Name, acFormatRTF, "H:\test.trf" > .Close > End With > > > > If you code Debug.Print qdfTemp.Name then you will see the name is #Temporary QueryDef#, but if you try using qdefTemp.name as show above then all you get is an error 3011, [Jet] database engine could not find the object '#Temporary QueryDef#'. > > So you need to create a real querydef, with a real name, and then delete it afterwards... > > Dim qdfNew as QuerDef > > Set qdfNew = .CreateQueryDef("NewQueryDef", "SELECT * FROM SomeTable") > DoCmd.OutputTo acOutputQuery, "NewQueryDef", acFormatRTF, "H:\test.trf" > CurrentDb.QueryDefs.Delete qdfNew.Name > > > Lambert > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust > Sent: Wednesday, September 01, 2010 12:00 PM > To: Access Developers discussion and problem solving > Subject: Re: [AccessD] DoCmd.OutputTo acOutputQuery with Temporary QueryDef > > I don't think I understand what you're doing. What are you trying to output the temporary query to? I've never tried to output a temporary query using code, so I'm not sure whether or not it's possible. A little more information might help. > > Charlotte Foust > > On Tue, Aug 31, 2010 at 3:32 PM, Brad Marks <BradM at blackforestltd.com> wrote: >> All, >> >> >> >> Is it possible to use the "DoCmd.OutputTo acOutputQuery" command with >> a Temporary QueryDef? >> >> >> >> I have experimented but cannot get this to work. I think that I am >> missing something. >> >> >> >> An example would be most appreciated. >> >> >> >> Thanks, >> >> Brad >> >> >> >> -- >> AccessD mailing list >> AccessD at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/accessd >> Website: http://www.databaseadvisors.com >> > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com >