PDA

View Full Version : query opens behind pop-up form problem



Knife1
06-08-2011, 07:46 AM
Hi

I have a pop-up form which users can click a button and run and open a query with DoCmd.OpenQuery. However the problem is the query always opens behind the pop-up by default. I thought the way to fix this would be to hide the form while the query is open. I can use Me.Visible = False to hide the form but I need the form to become visible again when query is closed. Onclose event procedure only works with forms I think so does anyone have any ideas for this?

Thanks

hansup
06-08-2011, 12:42 PM
So the starting form must remain a pop-up, right?

In that case, you can use the UnLoad property of the query datasheet to re-open the pop-up form (switch it from hidden to normal mode).

Since the query datasheet doesn't have a module, use a macro as the UnLoad property.

Create a macro to open your pop-up form in normal mode. Try the code below for the click event of the command button which opens the query. The code assumes you named the macro as "mcrReopenPopUp".

Private Sub cmdOpenQuery_Click()
DoCmd.OpenQuery "qryYourQueryName"
DoCmd.OpenForm Me.name, , , , , acHidden
Application.Screen.ActiveDatasheet.OnUnload = "mcrReopenPopUp"
End Sub

Knife1
06-10-2011, 07:56 AM
Hi hansup

Thanks, this sound good. I will try this. The starting form must be a pop-up before and after the query opens, doesn't matter what happens to it inbetween.

Cheers