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?

Thanks,
urjudoAsked:
Who is Participating?
 
PatHartmanCommented:
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.
1
 
dovidfCEOCommented:
Can you show the code?
0
 
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_Enter_Employer_Name_Click:
    Exit Sub

Err_Enter_Employer_Name_Click:
    MsgBox Err.Description
    Resume Exit_Enter_Employer_Name_Click
End Sub
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
urjudoAuthor Commented:
@PatHartman
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?
0
 
Dale FyeCommented:
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.
0
 
PatHartmanCommented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.