SQL gets erased/deleted when ran from a form

W

WannaChevy03

Hello,
I have a very frustrating problem. I have a form, with a "Run" button
that runs a query. Very simple, nothing to it. Except that after I run the
query from the form, it erases the SQL!!! It just becomes a blank query. If
I run the query from the design view, it is fine. Everything stays where it
should. Any suggestions on how to keep my SQL from being deleted???

Thanks,
Jessica Stout
 
J

John Vinson

Hello,
I have a very frustrating problem. I have a form, with a "Run" button
that runs a query. Very simple, nothing to it. Except that after I run the
query from the form, it erases the SQL!!! It just becomes a blank query. If
I run the query from the design view, it is fine. Everything stays where it
should. Any suggestions on how to keep my SQL from being deleted???

Thanks,
Jessica Stout

Care to post the button code?

Can't guess what you might be doing wrong if we can't see what you're
doing!

John W. Vinson[MVP]
 
W

WannaChevy03

Here is an example of the button code...


Private Sub cmdSpecQueryFormRunQuery_Click()
Ans = MsgBox("This query may take a minute. Continue?", vbOKCancel +
vbInformation, "Msgbox: OK or Cancel?")
If Ans = vbCancel Then Exit Sub

If IsNull(Combo3.Value) Then Text15.Value = "*"
If IsNull(Text15.Value) Then Text15.Value = "*"
If IsNull(Text5.Value) Then Text5.Value = "*"
If IsNull(Text7.Value) Then Text7.Value = "*"
If IsNull(Text9.Value) Then Text9.Value = "01/01/2005"
If IsNull(Text11.Value) Then Text11.Value = "01/01/2030"

If Combo3.Value = "" Then Text15.Value = "*"
If Text15.Value = "" Then Text15.Value = "*"
If Text5.Value = "" Then Text5.Value = "*"
If Text7.Value = "" Then Text7.Value = "*"
If Text9.Value = "" Then Text9.Value = "01/01/2005"
If Text11.Value = "" Then Text11.Value = "01/01/2030"


Dim rnum As Double
rnum = Rnd()
rnum = Left(rnum, 6) * 10000

If Option19.Value = True Then DoCmd.OutputTo acOutputQuery, "CR Query -
E", acFormatXLS, "C:\Temp\Output_" + CStr(rnum) + ".xls", True
If Option21.Value = True Then DoCmd.OutputTo acOutputQuery, "CR Query -
E, R", acFormatXLS, "C:\Temp\Output_" + CStr(rnum) + ".xls", True
If Option23.Value = True Then DoCmd.OutputTo acOutputQuery, "CR Query -
E, R, D", acFormatXLS, "C:\Temp\Output_" + CStr(rnum) + ".xls", True

End Sub
 

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