Solved Combos that disappear when I update them (1 Viewer)

MajP

You've got your good things, and you've got mine.
Local time
Today, 17:31
Joined
May 21, 2018
Messages
5,690
This issue has been discussed often and there are other variations to solve this problem

I find that the above method does not always work in a continuous form. I think it will work always in a datasheet. I use the trick I provided to be sure.
 

zelarra821

Registered User.
Local time
Today, 22:31
Joined
Jan 14, 2019
Messages
522
Good Morning, @MajP. I have detected a bug when it comes to linked combos, which may be mine, but hey, I have assembled this database for you to see. In your class module I have told you where the error occurs, and a Debug.Print so you can see what it does. I have also copied it on the form itself. You have four combos: status, multimedia, category and subcategory. Well, in category where the error occurs. I would not like to have to change the way of linking the combos because the way it is, everything is easier.

Update: Right now I have the call to the function in the On loading event, but the most logical thing would be that it was after updating the previous drop-down. Still, I keep giving the ruling. And I think it's because it doesn't change the reference to the form field to its corresponding value.

Thank you!
 

Attachments

  • Error.accdb
    680 KB · Views: 42
Last edited:

MajP

You've got your good things, and you've got mine.
Local time
Today, 17:31
Joined
May 21, 2018
Messages
5,690
The FAYT was not built to handle parameterized queries. Someday when I get around to it I will see if I can add it, but it would be pretty complicated to write. I never use parameterized queries so that is why I did not bother.

If I want cascading FAYT combos I change the row source of the combo on the On Enter event of the cascaded combo. You would then have to write code like this. In the example the Products combo is cascaded from the Supplier combo.

SQL:
Private Sub cmboCascadeProducts_Enter()
  Dim strSql As String
  strSql = "SELECT Products.ProductID, Products.ProductName FROM Products where SupplierName = '" & Nz(Me.cmboSupplier, "") & "' ORDER BY Products.[ProductName]"
  Me.cmboCascadeProducts.RowSource = strSql
  Me.cmboCascadeProducts.Requery
  'Important cascade code
  faytCascade.RowSource = strSql
End Sub

This is demonstrated in the FAYT code in the demonstration form.

In general you have to write code in the On Enter event to resolve the rowsource and then assign that to the FAYT rowsource and use the FAYT requery method. Do not try to assign the actual combo box these properties. Assign these to the the FAYT object.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 17:31
Joined
May 21, 2018
Messages
5,690
To make it work for Categoria.
1. Remove all row source from SrchCategoria
2. Add the code below
Code:
Public FAYT_Categoria As New FindAsYouTypeCombo

Private Sub Form_Load()
    FAYT_Categoria.InitalizeFilterCombo Me.SrchCategoria, "Categoría", Anywhereinstring, True, True
End Sub

Private Sub SrchCategoria_Enter()
Dim strSql As String
strSql = "SELECT TCategorias.Categoria AS Categoría, Sum(1) AS Archivos, TTiposDeMultimedia.TipoMultimedia AS Multimedia "
strSql = strSql & "FROM TEstados, TTiposDeMultimedia INNER JOIN TCategorias ON TTiposDeMultimedia.CodigoTipoMultimedia = TCategorias.CodigoTipoDeMultimedia "
strSql = strSql & "WHERE (((TCategorias.CodigoCategoria) <> 1) And ((TEstados.Estado) = '" & Me.SrchEstado & "')) "
strSql = strSql & "GROUP BY TCategorias.Categoria, TTiposDeMultimedia.TipoMultimedia "
strSql = strSql & "HAVING (((TTiposDeMultimedia.TipoMultimedia) = '" & Me.SrchMultimedia & "')) "
strSql = strSql & "ORDER BY TTiposDeMultimedia.TipoMultimedia, TCategorias.Categoria "
Me.SrchCategoria.RowSource = strSql
Me.SrchCategoria.Requery
'Important cascade code
FAYT_Categoria.RowSource = strSql
End Sub

If you want other combos to be FAYT you would need to do something similar in each On Enter event.
 

zelarra821

Registered User.
Local time
Today, 22:31
Joined
Jan 14, 2019
Messages
522
Thank you very much for answering. It was the solution I was handling, but I wanted to know if it was feasible, although I imagined it would not be easy. A greeting.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 17:31
Joined
May 21, 2018
Messages
5,690
It is actually not that hard if you look at my example in Post 24. Yours looked hard because the query is so long, but even that was just cut and paste.
 

Attachments

  • MajP_Error.accdb
    720 KB · Views: 42

zelarra821

Registered User.
Local time
Today, 22:31
Joined
Jan 14, 2019
Messages
522
I was not referring to the specific solution, I appreciate the inconvenience, I had understood how I had to do it. I was talking about implementing it in the module.
 

Users who are viewing this thread

Top Bottom