Multiple criteria search form that display results in subform (1 Viewer)

moylara85

New member
Local time
Today, 15:20
Joined
Feb 7, 2020
Messages
3
Hi guys, I'm pretty new at coding with VBA and I am workig on a project in which I would be able to track the different steps of an insurance claim. However I have got stuck while I'm creating the search form. I want to be able to show LIKE results for different fields that are part of different tables on a query that I had created already, is might be trying to do something that is not posible, what are my options on creating a multifield search form that displays the results in a continuous or datasheet subform? So far this is what I have wrote for the code of my search button but I keep getting errors, specially the Error type mismatch. Is it better to do it with macros? Is there a way to do it with macros or am I coding a lot of jiberish?

Thank you for your assistance.

SQL:
Private Sub btnBuscar_Click()

Dim SQL As String

SQL = "SELECT Siniestros.Siniestro, Siniestros.Reporte, Asegurados.Nom_Aseg, Beneficiarios.Nom_Ben, Siniestros.FechaSin, Vehiculos.VIN, Marcas.Marca, Tip_Veh.TIPO, Vehiculos.Placas" _
        & "FROM Beneficiarios RIGHT JOIN (Tip_Veh RIGHT JOIN ((Vehiculos RIGHT JOIN (Siniestros LEFT JOIN Asegurados ON Siniestros.Id_Aseg = Asegurados.ID_Aseg) ON Vehiculos.VIN = Siniestros.VIN) LEFT JOIN Marcas ON Vehiculos.ID_Marca = Marcas.ID_Marca) ON Tip_Veh.ID_Tipo = Vehiculos.Id_Tipo) ON Beneficiarios.Id_Ben = Siniestros.Id_Ben" _
        & "WHERE (((Siniestros.Siniestro) Like " * Me.txtSin * ")) " _
        & "AND ((Vehiculos.VIN) Like " * Me.txtVin * ")) " _
        & "AND (((Siniestros.Reporte) Like " * Me.txtRep * ")) " _
        & "OR ((Siniestros.FechaSin) Between #12/1/2019# And #1/1/2020#)" _   
        & "ORDER BY Siniestros.FechaSin DESC;"



Me.Resultados.Form.RecordSource = SQL
Me.Resultados.Form.Requery

End Sub
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 16:20
Joined
May 21, 2018
Messages
8,533
I want to be able to show LIKE results for different fields that are part of different tables on a query that I had created already, is might be trying to do something that is not posible, what are my options on creating a multifield search form that displays the results in a continuous or datasheet subform?
This is relatively easy and there are many ways to do it. I would not try what you are doing though. I would use the filter property. Here are a couple examples. If you can post your db it would help.
 

Attachments

  • FormFilterControl.zip
    38.2 KB · Views: 138
  • MajP SimpleSearch V2.zip
    89.7 KB · Views: 134

Users who are viewing this thread

Top Bottom