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

run query byitself.

Status
Not open for further replies.

amna77

Programmer
May 27, 2003
69
GB
hi i want my query to run byitself, when ever some one opens database. thats going to be update query, takes data from main table and puts that in table 2 and then delete duplicate values from table 2.
any help how to do that.
thanks in advance
 
You can create a form that opens invisible at the startup of your application. Run the query(s) in the On Open event of the form.

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]
[blue]Ask me about my grandson, get a grand answer.[/blue]
 

Is there a way to execute the query like a stored procedure? Can I have a VB app that calls MYAccessDB.Execute (qryMyQuery)?
 
You can do the execute. I believe you would need a reference set to a DAO library.

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]
 
This previous post is exactly what I am looking for, but I am not sure how to write the visual code. Below are a couple of events I have tried that are not working. Can someone please assist me how to correctly write it please? Currently I have an append query. Should I make it an update query before writing the code?

I have created a form based on the aquery "Count of OpenDeptCorp".

Private Sub Query1_Open(Cancel As Integer)
DoCmd.RunQuery "Count Of OpenDeptCorp"
End Sub

Private Sub Form_Open(Cancel As Integer)
DoCmd.RunCommand "Count Of OpenDeptCorp"
End Sub
 
An easier way to get the query to run whenever the database is started is simply to create an AutoExec macro which has one operation, to run the query. An AutoExec macro is just an ordinary macro with the specific name "AutoExec" - being named that way means it will automatically run when the database starts.

For more on AutoExec macro's check out
Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top