Brad Marks
BradM at blackforestltd.com
Thu Sep 2 13:00:45 CDT 2010
Charlotte, Thanks for your help. Yes, I could export the Report's RecordSource (the underlying query). The catch is that if the report has a filter, using the underlying query will return all records (not filtered). Brad -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust Sent: Thursday, September 02, 2010 10:07 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] DoCmd.OutputTo acOutputQuery with Temporary QueryDef That was what I was trying to figure out. I suppose you might do it by creating a recordset from the querydef and doing an export on the recordset object, but until the most recent explanation, I hadn't realized a report was involved. The report itself could be exported, of course, although the formatting would be lousy. I wonder if you could export the recordsource of the report and get the right data? Charlotte Foust On Wed, Sep 1, 2010 at 11:37 AM, Heenan, Lambert <Lambert.Heenan at chartisinsurance.com> wrote: > Hmm. I'm running Access 2003. > > If you had a temporary querydef, AKA an anonymous querydef, how would you make it the current object so that it could be exported? > > 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 2:07 PM > To: Access Developers discussion and problem solving > Subject: Re: [AccessD] DoCmd.OutputTo acOutputQuery with Temporary QueryDef > > 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 >> > > -- > 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 -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.