Why is my search button searching all fields? (1 Viewer)

Jared

Registered User.
Local time
Today, 00:51
Joined
Sep 10, 2008
Messages
21
I've put together a fairly complex personnel database. The most complex part of it is the main personnel form: there are so many pieces of information that might be entered for a given person that I've broken it down into one main form with the person's name and roles in our organization, with a lot of subforms below that (with what subforms are visible being controlled by what roles the person acts in).

I created a search button to allow people to search personnel by last name. In addition to the simple "Ctrl+F" function, I wrote into the code of the search button that it should set the focus to the txtLastName field.

The search function works great-but only so long as I don't click in any of the subforms. Once that happens, if I thereafter click the search button, it apparently searches every field-in every subform. This freezes up Access for 10-20 seconds at a time for each search, as I am up to over 2000 personnel records in the database. I wrote the code that sets the focus to the txtLastName field specifically to avoid problems like this, so...what's going on?

I'm attaching a stripped copy of my database. I've put in a lot of fake personnel data to simulate the problem's effects. "Librarian Example" should pop up as the first record. If you click on the "Consideration/Hiring Information" tab and click in a field or two there, then search for the last name "Test20" you'll get an error message about hiding a control that has the focus-why is my code to set the focus to the txtLastName field not bypassing that? If you click "Find Next," you'll get an error message that says "The control 'frmEducationSubform' the macro is attempting to search can't be searched." Why is the macro attempting to search there?

I have put a lot of code throughout the Personnel form and its many, many subforms, so I imagine it might be interfering-but I can't quite understand how, and so can't tell if there is a simple way around it short of radically simplifying and redesigning the form. I did some searches to see if this was a common issue, but I haven't found much in the way of similar problems, so I imagine I am missing something basic.

Thanks in advance for any help anyone can provide.
 

Attachments

  • DB With Search Issue.zip
    621 KB · Views: 134

HAMMAMABUARQOUB

Registered User.
Local time
Today, 07:51
Joined
Jul 29, 2009
Messages
75
first of all you did a great job by analysing this all and put the system into action, but i will be honnest with you, you will find it very difficult in the future to redesign and update the forms like this way! I am not pretending to be an expert, but, as my experience in interface design and how much is very related to programming i suggest you reconsider most of the designs in your database so it can take any codes without problems..
Again I am not trying to under-estimate your works, contrary, it's very fine and well done! but, i need you to take a look at these screenshots from a programme i made,, i use buttons with subforms rather than subforms with tabs, why? 1st, i see it more elegant design 2nd easier forcoding,, that's all...

===================================
 

Attachments

  • bas - Copy.jpg
    bas - Copy.jpg
    70.1 KB · Views: 413
  • ser.jpg
    ser.jpg
    75.3 KB · Views: 366

Jared

Registered User.
Local time
Today, 00:51
Joined
Sep 10, 2008
Messages
21
Ah, so with the button setup you recommend, clicking each button just changes which subform is actually present? That probably is a bit more elegant, as the code in the subforms then actually isn't present to interfere with each other. It sounds like it might make the database a bit less RAM-intensive, as well, since it doesn't have to hold all the forms in memory simultaneously.
 

Users who are viewing this thread

Top Bottom