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

set focus on Query

Status
Not open for further replies.

yummy7

Technical User
Jun 2, 2006
195
CA
Actually the following code was working excellent and meet my criteria.
CurrentDb.QueryDefs("Query2").SQL = "SELECT " & strList & " from Store_t where " & GetCriteria()
DoCmd.OpenQuery "Query2", acViewPreview, acReadOnly

But this query opens behind all the forms.So that i cannot see it.I want it to be focused when it is openend,Infront of user.How I can set focus on Query2.
Please help me in this regard.
 
I expect your forms are open in Dialog mode so they are in front. Consider binding your query to a new dialog form and opening 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]
 
Thanx dhookom,
I made all forms dialog mode so that user should not able to go in design mode of forms.Is there any alternative solution.Because through form its not working.Query is flexible in feilds selection to be selected. And not showing following criteria.
CurrentDb.QueryDefs("Query2").SQL = "SELECT " & strList & " from Store_t where " & GetCriteria()
Shall be grateful to you.
 
The form solution can work if you set it up correctly. You can create a form with a subform object on it. In the On Open event of the form, set the source object to your query.
Code:
Me.subformctrl.SourceObject = "Query.Query2"

Open the main form with acDialog so it appears on top. The query will appear as a datasheet on 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]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top