SQL gets erased/deleted when ran from a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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]
 
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
 
Back
Top