SQL erases after the query is ran

G

Guest

Hi,
I have built a form, with a "run" button that runs multiple queries...

DoCmd.OpenQuery ("Get1 Spec Revs")
DoCmd.OpenQuery ("Get2 Plant Forms")
DoCmd.OpenQuery ("Get3 More Data")
If Check89 = True Then DoCmd.OutputTo acOutputQuery, "Get4 No HSI Form",
acFormatXLS, "C:\Temp\Output.xls", True

The first 3 queries are make-table queries, and the fourth is not. All 4
queries run just fine, and I get the data that I need, however, I can't run
it a second time because the SQL erases itself in the fourth query only!!!
This is VERY frustrating because I have to constantly copy and paste the SQL
back into it. Any suggestions?

Thanks!
Jessica
 
O

OfficeDev18 via AccessMonster.com

Is "Get4 No HSI Form" a query residing on the Query tab of your database? How
about posting the query's SQL so we can get a look at it?

Sam
 
G

Guest

Yes, it does reside on the query tab of my database. Here is the SQL for #4...

SELECT More_Data.PITEM_ID AS Specification, More_Data.PITEM_REVISION_ID AS
Revision, More_Data.PCREATION_DATE AS Date_Revised, More_Data.POS_USERNAME AS
Who_revised, More_Data.INFODBA_PWORKSPACEOBJECT_POBJECT_TYPE AS Object_Type
FROM More_Data
WHERE (((More_Data.PCREATION_DATE) Between [Forms]![No HSI
PRF]![CreateStart] And [Forms]![No HSI PRF]![CreateEnd]) AND
((More_Data.INFODBA_PWORKSPACEOBJECT_POBJECT_TYPE) Like [Forms]![No HSI
PRF]![DocType] And
(More_Data.INFODBA_PWORKSPACEOBJECT_POBJECT_TYPE)<>"End_Item Revision Master"
And (More_Data.INFODBA_PWORKSPACEOBJECT_POBJECT_TYPE)<>"SalesOrder Form" And
(More_Data.INFODBA_PWORKSPACEOBJECT_POBJECT_TYPE)<>"Alloy_Item Revision
Master" And (More_Data.INFODBA_PWORKSPACEOBJECT_POBJECT_TYPE)<>"Commodity
Sales Form" And
(More_Data.INFODBA_PWORKSPACEOBJECT_POBJECT_TYPE)<>"PlantReview Form" And
(More_Data.INFODBA_PWORKSPACEOBJECT_POBJECT_TYPE)<>"Category Form") AND
(([More_Data].[PITEM_ID] & [More_Data].[PITEM_REVISION_ID]) Not In (SELECT
More_Data.PITEM_ID & More_Data.PITEM_REVISION_ID FROM More_Data WHERE
INFODBA_PWORKSPACEOBJECT_POBJECT_NAME="G1A.HSI-Plant Review")))
ORDER BY More_Data.PITEM_ID, More_Data.PITEM_REVISION_ID;
 
O

OfficeDev18 via AccessMonster.com

I dunno. Anybody?

Sam
Yes, it does reside on the query tab of my database. Here is the SQL for #4...

SELECT More_Data.PITEM_ID AS Specification, More_Data.PITEM_REVISION_ID AS
Revision, More_Data.PCREATION_DATE AS Date_Revised, More_Data.POS_USERNAME AS
Who_revised, More_Data.INFODBA_PWORKSPACEOBJECT_POBJECT_TYPE AS Object_Type
FROM More_Data
WHERE (((More_Data.PCREATION_DATE) Between [Forms]![No HSI
PRF]![CreateStart] And [Forms]![No HSI PRF]![CreateEnd]) AND
((More_Data.INFODBA_PWORKSPACEOBJECT_POBJECT_TYPE) Like [Forms]![No HSI
PRF]![DocType] And
(More_Data.INFODBA_PWORKSPACEOBJECT_POBJECT_TYPE)<>"End_Item Revision Master"
And (More_Data.INFODBA_PWORKSPACEOBJECT_POBJECT_TYPE)<>"SalesOrder Form" And
(More_Data.INFODBA_PWORKSPACEOBJECT_POBJECT_TYPE)<>"Alloy_Item Revision
Master" And (More_Data.INFODBA_PWORKSPACEOBJECT_POBJECT_TYPE)<>"Commodity
Sales Form" And
(More_Data.INFODBA_PWORKSPACEOBJECT_POBJECT_TYPE)<>"PlantReview Form" And
(More_Data.INFODBA_PWORKSPACEOBJECT_POBJECT_TYPE)<>"Category Form") AND
(([More_Data].[PITEM_ID] & [More_Data].[PITEM_REVISION_ID]) Not In (SELECT
More_Data.PITEM_ID & More_Data.PITEM_REVISION_ID FROM More_Data WHERE
INFODBA_PWORKSPACEOBJECT_POBJECT_NAME="G1A.HSI-Plant Review")))
ORDER BY More_Data.PITEM_ID, More_Data.PITEM_REVISION_ID;
 
G

Guest

I'm having exactly the same problem as WannaChevy03 - running an OutputTo and
the SQL is being erased after the Query. Have found lots of references to
this problem on the net, but no solutions.

Anybody got any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top