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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stop user saving a query

Status
Not open for further replies.

nq

IS-IT--Management
Apr 1, 2002
102
AU
I have a database with many predefined queries/reports. These are sufficient for all users except one. This user would like to create temporary queries on an ad hoc basis. I can add a command button to invoke the QBE query menu:

DoCmd.RunCommand acCmdNewObjectQuery

However, this will allow the user to save the query when exiting. Eventually this will cause database "bloat". Is there a way of preventing the user saving the query or automatically deleting it afterwards?
 
Import the Query By Form applet from or suggest that if he/she is really a smart person, they should be able to query the data from Excel.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Duane.
Thanks for the reply.
Problem solved. The following code works as a global module.

Public Function Temp_Query()

Dim stDocName As String
Dim stTempName As String

stDocName = "qryUserDefined"
stTempName = "qryUserTemp"

On Error Resume Next
DoCmd.DeleteObject acQuery, stTempName
DoCmd.CopyObject , stTempName, acQuery, stDocName

DoCmd.ShowToolbar "RunQuery", acToolbarYes
DoCmd.OpenQuery stTempName, acViewDesign, acEdit

DoCmd.RunCommand acCmdShowTable

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top