How to close auto-close Query result if not active

SachAccess

Active member
Local time
Today, 16:05
Joined
Nov 22, 2021
Messages
437
Hi,

I have a Form in my DB.
I have provided a Button in my DB.
Button is linked to below code.
Once clicked it takes user to query result.
At present when user clicks on button ‘Code and Name ‘ from ‘Emp Code and Name’ form.
Both query ‘Q_Select_Only_Two_Column’ and form ‘Emp Code and Name’ are visible, which is fine.

However when user returns to form even then also both are visible.
My question is, once user is back to Form how do I auto-close the query result.
Thanks.
Code:
Option Compare Database
'Form Get Employee Details
Private Sub Command5_Click()
DoCmd.OpenQuery "Q_Select_Only_Two_Column"
End Sub
 
Hi. You could try using the DoCmd.Close method in the Activate event of the Form. However, you shouldn't give users direct access to query result. You could create a form to display the result of the query and then use DoCmd.Close in its LostFocus event.
 
Hi @theDBguy sir, thanks a lot for the help. Sure, I will keep this in mind.
Have a nice day ahead. :)
 

Users who are viewing this thread

Back
Top Bottom