Filter Combo As You Type (Prefix) (1 Viewer)

dgreen

Member
Local time
Today, 01:26
Joined
Sep 30, 2018
Messages
397
@MajP
See attached file. I'm using your code for the FAYT and am having issues implementing for my prefix column. I've gotten it to work on the Combo7 (showing the organizations), so I do know that it works.

Issues:
1) When I start typing in Combo5 it doesn't open to display the filtered results.
2) It doesn't filter as you type.

Visual of issue 1
1584892440087.png

Visual of opened drop down that isn't filtering
1584892526237.png

The difference between the 2 combo boxes, other than data source, is that for Prefix I don't display the search field and I'm showing more than 2 columns in the combo box.
 

Attachments

  • FAYT_Challenge.zip
    82.2 KB · Views: 202

zeroaccess

Active member
Local time
Today, 01:26
Joined
Jan 30, 2020
Messages
671
Honestly for a drop down list that small, I wouldn't bother with FAYT. I want my users to see the options available. YMMV.
 

dgreen

Member
Local time
Today, 01:26
Joined
Sep 30, 2018
Messages
397
The actual list is much larger. It's just a test dataset to help me get the code right and working.
Honestly for a drop down list that small, I wouldn't bother with FAYT. I want my users to see the options available.
 

zeroaccess

Active member
Local time
Today, 01:26
Joined
Jan 30, 2020
Messages
671
Well you said FAYT isn't working, and it clearly doesn't look like it is in your screen shot, so I assumed that was the full list.
 

dgreen

Member
Local time
Today, 01:26
Joined
Sep 30, 2018
Messages
397
@zeroaccess Do you see anything wrong in the attached demo database (post 1) that might shed light as to why it's not working?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:26
Joined
May 21, 2018
Messages
8,527
Code:
Public faytPrefix As New FindAsYouTypeCombo
Public faytOrg As New FindAsYouTypeCombo

Private Sub Form_Open(Cancel As Integer)
    faytPrefix.InitalizeFilterCombo Me.Combo5, "Prefix_Search", AnywhereInString, True, False
    faytOrg.InitalizeFilterCombo Me.Combo7, "ORG_Search", AnywhereInString, True, False
End Sub

What is interesting is this works way better than a cascading combobox. You do not lose visibility in a continuous form.
 

dgreen

Member
Local time
Today, 01:26
Joined
Sep 30, 2018
Messages
397
@MajP - Thanks. Updated file attached for others to reference.
The fix was the update the Public Function on the Form Open to make each fayt unique and then update the Private Function to match.

Code:
Public faytPrefix As New FindAsYouTypeCombo
Public faytOrg As New FindAsYouTypeCombo

Private Sub Form_Open(Cancel As Integer)
    faytPrefix.InitalizeFilterCombo Me.Combo5, "Prefix_Search", AnywhereInString, True, False
    faytOrg.InitalizeFilterCombo Me.Combo7, "ORG_Search", AnywhereInString, True, False
End Sub

What is interesting is this works way better than a cascading combobox. You do not lose visibility in a continuous form.
 

Attachments

  • FAYT_Challenge v2.zip
    118.3 KB · Views: 200

zeroaccess

Active member
Local time
Today, 01:26
Joined
Jan 30, 2020
Messages
671
Code:
Public faytPrefix As New FindAsYouTypeCombo
Public faytOrg As New FindAsYouTypeCombo

Private Sub Form_Open(Cancel As Integer)
    faytPrefix.InitalizeFilterCombo Me.Combo5, "Prefix_Search", AnywhereInString, True, False
    faytOrg.InitalizeFilterCombo Me.Combo7, "ORG_Search", AnywhereInString, True, False
End Sub

What is interesting is this works way better than a cascading combobox. You do not lose visibility in a continuous form.
Can you explain what you mean by "lose visibility"?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:26
Joined
May 21, 2018
Messages
8,527
If you do a cascading combobox in a continous form and filter the second combobox, all previous records with their values filtered out of the rowsource will appear to go blank. Requires a pretty significant workaround.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:26
Joined
May 21, 2018
Messages
8,527
@dgreen
If you look at my FAYT listbox, it allows you to filter on one specified column or any column. Works well in a listbox. In a combobox I found it confusing so did not include the same code to do that. If needed it would be a pretty easy fix.
 

dgreen

Member
Local time
Today, 01:26
Joined
Sep 30, 2018
Messages
397
Also for me, using my other technique, I was passing the search value to the rowsource so every other combo box that I already had a value for would start to filter out visually. Nothing was deleted but you wouldn't see the different values until you left the current combo box.
 

zeroaccess

Active member
Local time
Today, 01:26
Joined
Jan 30, 2020
Messages
671
If you do a cascading combobox in a continous form and filter the second combobox, all previous records with their values filtered out of the rowsource will appear to go blank. Requires a pretty significant workaround.
Ahh, yes. My workaround for that was to create an unbound popup form for the second combo. You make your selection there and it passes the value back to the 2nd combo box, which is disabled and locked (a small button next to it opens the popup form). My case is different though - more detail is needed to be displayed in that window, so not just a simple cascading filter like dgreen. Your solution looks like a good one for that. I've never seen anyone come up with a solution like this before.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:26
Joined
May 21, 2018
Messages
8,527
Your solution looks like a good one for that. I've never seen anyone come up with a solution like this before.
This is not intended as a solution for a continuous cascade, it just has that as a benefit. The approach I use for cascading is here
You can do this with a couple of code events, however that solution is problematic. This works better.
 

Attachments

  • CascadeContinous.zip
    84.4 KB · Views: 216

dgreen

Member
Local time
Today, 01:26
Joined
Sep 30, 2018
Messages
397
Take a look at this approach. It has a requery on the State [Combo15] that updates the City list [Combo13] when changed. The data source for the City combo has a criteria of [Forms]![f_Users]![Combo15].

I'm getting a too many parameters error, not sure what's causing it.... But it's working on my end. Thoughts?
 

Attachments

  • FAYT_Challenge v3.zip
    113.3 KB · Views: 178

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:26
Joined
May 21, 2018
Messages
8,527
Code:
Private Sub Combo13_Enter()
  Dim strSql As String
  strSql = "SELECT t_City_State.City, t_City_State.State_Abrv FROM t_City_State WHERE t_City_State.State_Abrv = '" & Nz([Forms]![f_Users]![Combo15], "") & "'"
  Combo13.RowSource = strSql
End Sub

Private Sub Combo13_Exit(Cancel As Integer)
  Dim strSql As String
  strSql = "SELECT t_City_State.City, t_City_State.State_Abrv FROM t_City_State"
  Combo13.RowSource = strSql
End Sub
 

dgreen

Member
Local time
Today, 01:26
Joined
Sep 30, 2018
Messages
397
@MajP
I put your code in and while it's still giving me a error "3061 too few parameters. Expected 1.", it's working.... Can you look around and see if you can figure out what's causing the error?

Code:
Private Sub Combo13_Enter()
  Dim strSql As String
  strSql = "SELECT t_City_State.City, t_City_State.State_Abrv FROM t_City_State WHERE t_City_State.State_Abrv = '" & Nz([Forms]![f_Users]![Combo15], "") & "'"
  Combo13.RowSource = strSql
End Sub

Private Sub Combo13_Exit(Cancel As Integer)
  Dim strSql As String
  strSql = "SELECT t_City_State.City, t_City_State.State_Abrv FROM t_City_State"
  Combo13.RowSource = strSql
End Sub
 

Attachments

  • FAYT_Challenge v4.zip
    124.3 KB · Views: 184

dgreen

Member
Local time
Today, 01:26
Joined
Sep 30, 2018
Messages
397
Maybe the quotes aren't quite right in the combo13_Enter code?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:26
Joined
May 21, 2018
Messages
8,527
get rid of the macro.
 

dgreen

Member
Local time
Today, 01:26
Joined
Sep 30, 2018
Messages
397
Macro is gone, still erroring. V5 attached.
 

Attachments

  • FAYT_Challenge v5.zip
    51.9 KB · Views: 147

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:26
Joined
May 21, 2018
Messages
8,527
Remove the form's reference in the rowsource of the city combo. Change to
SELECT t_City_State.City, t_City_State.State_Abrv
FROM t_City_State;
 

Users who are viewing this thread

Top Bottom