1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
Private Sub Btn_Recherche_Click()
Dim strTable As String, strField As String, strCriteria As String, strSql As String, strSqlWhere As String
Dim Criter As Variant
Dim intTypChamp As Integer
Dim intOpeChamp As Integer
strTable = Me.cbo_Table 'recup nom table
strField = Me.cbo_Champ 'recup nom champ
'compose critere de recherche
intTypChamp = lf_GetTypeField(strTable, strField) 'pour trouver type champs
intOpeChamp = Me.opt_Recherche
Select Case intTypChamp
...
End Select
If Me.Opt_RechCourante And Not Len(Me.lst_Resultat.RowSource) = 0 Then
If Not Me.lst_Resultat.RowSource Like "*FROM " & strTable & "*" Then
MsgBox "La búsqueda precedente no trata de la misma tabla que esta búsqueda" = vdExclamation + vbOKOnly, "Error"
Exit Sub
End If
strSql = Left(Me.lst_Resultat.RowSource, Len(Me.lst_Resultat.RowSource) - 3)
strSql = strSql & " AND " & strCriteria & "));"
Else
'construit la requete sql
strSql = "SELECT DISTINCTROW " & strTable & ".*"
strSql = strSql + " FROM " & strTable
strSql = strSql + " WHERE ((" & strCriteria & "))"
strSqlWhere = Trim(Right(strSql, Len(strSql) - InStr(strSql, "Where ") - Len("Where ") + 1))
strSql = strSql & ";"
End If
Me.lbl_Stats.Caption = DCount("*", strTable, strSqlWhere) & " / " & DCount("*", strTable)
Me.lst_Resultat.RowSource = strSql 'affecte sql a lst_Resultat
Me.lst_Resultat.Requery 'recalcule la liste
Private Sub lst_Resultat_DblClick(Cancel As Integer)
DoCmd.OpenForm "Formulario5", acNormal, , "[Codigo] = " & Chr(34) & Me.lst_Resultat & Chr(34)
End Sub |
Partager