Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Message Box In Query

Status
Not open for further replies.

JHHPavel

Technical User
Jul 18, 2003
29
US
My basic question is how to make a query show a message box before it runs. I tried adding the final MSGBOX line to the SQL below for a simple querey, but it says I'm missing an operator. I tried putting OPEN before MSGBOX but that didn't work either. How do I get the query to show a message box?

SELECT Tbl_01_FY05.Type, Tbl_01_FY05.VarNetMargin
FROM Tbl_01_FY05
WHERE (((Tbl_01_FY05.Type)="HAL"))
MSGBOX "Main table indexed?";

Beyond getting just a simple message, the ultimate goal is to have an inter-active message box asking a question and allowing the answers "Yes" or "No". If you click "Yes", the query runs; if you click "No" it gives you a message to index the main table, then shuts off.

Thanks for your help.
 
Why not have a procedure that runs the query if the user answers a particular MsgBox?

Code:
Public Sub RunQuery()
if msgbox("Main table Indexed?", vbyesno, "Index") = vbyes then
   docmd.runsql "SELECT Tbl_01_FY05.Type, Tbl_01_FY05.VarNetMargin " & _
                "FROM Tbl_01_FY05 " & _
                "WHERE (((Tbl_01_FY05.Type)="HAL"))"
End if
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top