Access Query display

Hi Experts,
I have a form "Employer" there is a command button for search an employer, once user enter first few letters of the employer, it will open a query for them to see all the employers with the same first few letters that user enter.  my problem is every time when the query opens, it opens behind the form, is any way I can bring the query in front of the form?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Can you show the code?
urjudoAuthor Commented:
here is the code:
Private Sub Enter_Employer_Name_Click()
On Error GoTo Err_Enter_Employer_Name_Click

    Dim stDocName As String
    stDocName = "qryEmployerByName"
    DoCmd.OpenQuery stDocName, acNormal, acEdit
    Exit Sub

    MsgBox Err.Description
    Resume Exit_Enter_Employer_Name_Click
End Sub
NEVER, EVER open a raw query for users to interact with.  Unless you made the query not updateable (which you did not), the user can simply modify the data in the query and that will be saved to the underlying table.  Even WORSE, they can actually delete records.

Always use a form.  That way your code in the form's BeforeUpdate event can validate the changes and ensure only good data gets saved.   Using a form will also resolve the problem you are having with it opening behind the current form.  If the current form is opened as model, you may have to change that to allow something to open on top of it.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

urjudoAuthor Commented:
I was thinking to use datasheet query just because only two users can access to update the table, so your suggest is use a form instead a query and the two users can modify on the form, is correct?
Dale FyeOwner, Developing Solutions LLCCommented:
I agree with Pat, "Always use a form"

In addition to displaying the results of the query in a form, if there are more fields there than you want to edit in a datasheet or a continuous form, you might also provide a way for the use to double click on the record selector of the datasheet and open the main form for editing the Employee record.
It doesn't matter how many users can access the database.  Your job is to protect them from themselves.  I am a very experienced developer.  If I have to modify production data (which I avoid like the plague), I always use the same form I gave the users.  The form has all the validation code and it ensures the data is correct before it is saved.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.