Jackblack1
Active Member
- Joined
- Feb 10, 2004
- Messages
- 266
If I have a Run query button on a form, and I want the query to run in the background and not display the query form, How do I do this?
Utlimately, I would like to refresh the form by clicking the refresh button on the form and have it run the query in the background. I have the code for the two listed below, can anyone help me join them. How could I combine the two macro so that it does this.
If you really want to be slick, The query i am running is a subform in a form, can you get it so the subform updates when you click the refresh button?
Form name = Duplicates
SubForm name = lstGratuityduplicates
Thanks Jim
The code I have so far linked to the run query button.
Private Sub run_query_Click()
On Error GoTo Err_run_query_Click
Dim stDocName As String
stDocName = "Find_duplicates_entries_Gratuities_List"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_run_query_Click:
Exit Sub
Err_run_query_Click:
MsgBox Err.Description
Resume Exit_run_query_Click
End Sub
For the refresh button, the code is:
Private Sub openclose_Click()
On Error GoTo Err_openclose_Click
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.Close
stDocName = "duplicates"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_openclose_Click:
Exit Sub
Err_openclose_Click:
MsgBox Err.Description
Resume Exit_openclose_Click
End Sub
Utlimately, I would like to refresh the form by clicking the refresh button on the form and have it run the query in the background. I have the code for the two listed below, can anyone help me join them. How could I combine the two macro so that it does this.
If you really want to be slick, The query i am running is a subform in a form, can you get it so the subform updates when you click the refresh button?
Form name = Duplicates
SubForm name = lstGratuityduplicates
Thanks Jim
The code I have so far linked to the run query button.
Private Sub run_query_Click()
On Error GoTo Err_run_query_Click
Dim stDocName As String
stDocName = "Find_duplicates_entries_Gratuities_List"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_run_query_Click:
Exit Sub
Err_run_query_Click:
MsgBox Err.Description
Resume Exit_run_query_Click
End Sub
For the refresh button, the code is:
Private Sub openclose_Click()
On Error GoTo Err_openclose_Click
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.Close
stDocName = "duplicates"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_openclose_Click:
Exit Sub
Err_openclose_Click:
MsgBox Err.Description
Resume Exit_openclose_Click
End Sub