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

Find As Your Type Combobox 1

Status
Not open for further replies.

malbreht

Technical User
Dec 8, 2006
63
SI
Hi!

I'm stuck at using the faq . These two lines are red
Code:
Private WithEvents mCombo As Access.ComboBox
Private WithEvents mForm As Access.Form
and I'm not sure what to do with it...

These are supposed to be instructions:
Code:
Option Compare Database
Option Explicit

'Class Module Name: FindAsYouTypeCombo
'Purpose: Turn any combobox into a "Find As You Type" 'Combobox 
'Created by: MajP
'Demonstrates: OOP, and With Events
'
'Use:To use the class, you need code similar to the 'following in a form's module. 
'Also requires a reference to DAO
'Two properties must be set: FilterComboBox
'and FilterFieldName.  These are the combo box object
'and the name of the field that you are filtering.
'
'Public faytCombo As FindAsYouTypeCombo
'
'Private Sub Form_Open(Cancel As Integer)
'  Set faytCombo  = New FindAsYouTypeCombo
'  Set faytCombo.FilterComboBox = Me.YourComboBoxName
'  faytCombo.FilterFieldName = "strLastName"
'End Sub
'
'

Can anybody explain a little bit more precisely?

Thank you very much!
Mare
 
Did you paste the code into a class module?
 
I pasted it as a new module "FindAsYouTypeCombo" - is that ok?
 
No, you must choose Class Module. You will find it on the Insert menu or in the dropdown.
 
OK, that's done...but what exactly does that mean:

Code:
'Use:To use the class, you need code similar to the 'following in a form's module. 
'Also requires a reference to DAO
'Two properties must be set: FilterComboBox
'and FilterFieldName.  These are the combo box object
'and the name of the field that you are filtering.
'
'Public faytCombo As FindAsYouTypeCombo
'
'Private Sub Form_Open(Cancel As Integer)
'  Set faytCombo  = New FindAsYouTypeCombo
'  Set faytCombo.FilterComboBox = Me.YourComboBoxName
'  faytCombo.FilterFieldName = "strLastName"
'End Sub
'
'

If I understand this correctly, I have to copy this to the form's module?

Many, many thanks!
 
I guess you have done this already. Has it worked out?
 
Not actually, if I paste this
Code:
Public faytCombo As FindAsYouTypeCombo

  Set faytCombo = New FindAsYouTypeCombo
  Set faytCombo.FilterComboBox = Me.Employee_ID_combo
  faytCombo.FilterFieldName = "strSurname"
End Sub

... at the beginning of the form's code (I replaced the Me.YourComboBoxName and "strLastName") I get error mesage "Invalid outside procedure".

Any ideas?

Thanks!
 
According to the instructions, this:

[tt] Set faytCombo = New FindAsYouTypeCombo
Set faytCombo.FilterComboBox = Me.Employee_ID_combo
faytCombo.FilterFieldName = "strSurname"[/tt]

Goes in:
[tt]Private Sub Form_Open(Cancel As Integer)[/tt]

That is, the form open event.

Are you sure you are not making life too complicated? This code was built from a thread I responded to:
Combobox as Find As You Type?
thread702-1228727
And the idea is that each letter anywhere counts, so SW matches Steward, which, I suppose, may be useful, but I think that your users will expect ST or even S to match Steward, which can be achieved by setting the Auto Expand property of the combo to Yes.

Just curious, but why did:
Choosing a record in a combo
thread702-1317810
No longer suit?


 
Oh, THANKS man! It works now and I am the happiest man alive :) And, yeah, I'm probably making my life too complicated but I really wanted exactly this. Your listbox & textbox suggestion worked just fine, but I really enjoy learning Access and trying as much options as I can...

Thanks again,
Mare
 
And just to excuse myself - now that I look back the instructions in faq are completely understandable (but when you don't know what you have to do and english is not your 1st language, well, then you have to ask at tek-tips:)

Sorry again for stupid questions.
 
That's fair enough. A desire to learn is an excuse for a great deal. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top