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

Getting a combo box to search inside the string

Status
Not open for further replies.

bhujanga

Programmer
Oct 18, 2007
181
US

What I want to do is be able to use a combo box (or something like it) to pare down the drop-down list based on what I'm typing in the field, but instead of just being sensitive to whether the associated text begins with that text, is sensitive to whether that text is embedded anywhere within the string. To put it another way, the typing space in combo boxes react using: LIKE "string*" logic and I want it to use LIKE "*string*" logic.

Can this be done?
 
Faq702-6304
just read the instructions very carefully.
 
Thanks. I've never worked with class modules before, but I did a little googling and studied the code you referenced and I think I get it. I'll see if I can make it work tomorrow. It's possible I'll have a question or two if I can't get it to work as I expect it to.

It looks like I can copy the entirety of the code into the new class module and put the declaration at the top of he form's code module and the only thing that is specific to my situation will be the few lines that I put in the Form Load() event code. Since I want it to search interior text, I use FALSE for the third parameter as shown in their example.

Am I correct on all counts?
 
Yes. If you do everything correctly, it is nothing but a cut and paste job. That is the beauty of custom classes, they are reusable.
 
I'm having trouble making this work.
I even made a boiled down form so I know there's nothing else creating conflict but I keep getting the following error message:
"The expression On Load you entered as the event property setting produced the following error: User-defined type not defined"

The field I'm using is called product as is the text box on the form that references that field. The combo box that I'm using for the filtering is called cmbProducts. I created the class module called FindAsYouTypeCombo and pasted the sample code directly into it, then I put these statements at the beginning of the forms code module:

Option Compare Database
Option Explicit
Public faytProducts As New FindAsYouTypeCombo

Private Sub Form_Load()
faytProducts.InitalizeFilterCombo Me.CmbProducts, "Product", False
End Sub

Do you know why it doesn't work? (Note: In the sample the second parameter was shown with only the closing quotes, as a result I've tried it both with no quotes and with quotes and get the same error.)
 
It does not recognize the line
Public faytProducts As New FindAsYouTypeCombo

Either the name of you class module is not spelled exactly "FindAsYouTypeCombo"
Or it is not in a class module but in a standard module.

If it is correct then after the word new the intellisense should show it in the list of objects.
 
I double checked these things and everything seems ok, but I still get the error. I even deleted the name and let the intellisense bring it up just in case my eyes were playing tricks on me - still no luck. Is it possible that there is a setting or something that needs to be made for Access to be able to use class modules?
 
Hit the debug in the VBE and see if it hilites anything. My next guess is that you do not have a reference to DAO (data access objects). In the class there is this line
Private mRsOriginalList As DAO.Recordset

If you do not have a reference to DAO, you will get that type of error.

This error can often be a spelling mistake or a reference issue

assume you meant to dimension a string, but typed

dim strSomeString as streng

since there is not datatype called streng it assumes you made a user defined datatype. Then it searches the rest of the code for a place where you define a streng datatype. But since you did not define a streng or intend to (only a spelling error) you get
user defined type not defined.

Some object definitions are contained in external libraries, and you have to add them with a reference. If the reference is not added it again assume you are using a user defined datatype.

So in truth it is a crappy message should say.
Dimensiond Data type is misspelled, or no reference added for data type, or user defined data type not defined. Check spelling, references, or define the data type.
 
Thanks for all your help. I need to put this problem on the back burner for a little while so I haven't got it working yet, but I'll try to hammer it out eventually. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top