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

Modification to FindAsYouTypeListBox and Combo classes to let it self-terminate.

Status
Not open for further replies.

BenSacheri

Programmer
Oct 13, 2015
14
US
thread702-1716817
thread702-1765353

These two threads are closed for the awesome FindAsYouTypeListBox and FindAsYouTypeCombo classes created by MajP but I wanted to share this small addition.

myself said:
If you don't know about the FindAsYouTypeListBox class, it will let you have a textbox above a listbox. As you type into the textbox, the listbox will automatically filter, like an Autocomplete list. This class can be applied to any existing listbox with only a few lines of code.

The FindAsYouTypeCombo will convert a combo box into a Autocomplete style box that will shorten the list to match the letters you type.

These both work in memory so and don't need to requery the server with each filter.

If you open and close the form that uses this class too many times, Access may crash unless you've remembered to add code to terminate the class. You can add these two bits to your code and the class will self-terminate. It works because the class already has a reference to the parent form, so it can monitor the Form_Close event on the form and terminate the class when it fires.


In the Initalize() (or InitalizeFilterCombo) sub, add this OnClose line below the exiting OnCurrent line:

Code:
mForm.OnCurrent = "[Event Procedure]" ' below this line 
mForm.OnClose = "[Event Procedure]" ' <- this is the new line

Then add this sub:

Code:
Private Sub mForm_Close()
' By tapping into the form events FROM this class, I can tap into the Close event
' so I don't need to have the cleanup code in the form. "Cleaner" this way I think. -TSC

    Call Class_Terminate

End Sub


Please share some feedback if you are using either of these classes. I have made a few other changes but don't want to waste my time if no one is using them.

Ben
 
I added you code to the FAQ. I do not understand why this would help, but I cannot see any problem with adding it. I would think if you close and open the form multiple times, every time you close the form the reference to the class decrements and the instance goes out of scope. So I would think this would all take care of itself.
 
Another developer and I have both experienced some abrupt Access crashing when going back and forth from Design mode to Form mode of a form that used this code. Adding this terminate code seems to have resolved that problem. Your mileage may vary.

Can you provide a link to the "FAQ" you updated? I'm curious if there is a master version of these two classes being maintained somewhere. It would be nice if they were in something like GitHub to better support contributions and updates. I think these classes are very useful additions for Access developers.
 
faq702-6304
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top