J'y ai pensé bien sur... Mais il n'y a pas que les requetes SQL à changer, c'est bien pour cela que je n'y arrive pas.
Voilà ce que j'ai fais pour le SQL:
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
| Private Sub Form_Load()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case Left(ctl.Name, 3)
Case "chk"
ctl.Value = -1
Case "lbl"
ctl.Caption = "- * - * -"
Case "txt"
ctl.Visible = False
ctl.Value = ""
Case "cmb"
ctl.Visible = False
End Select
Next ctl
Me!lstResults.RowSource = "SELECT ProduitsClient.id_ProduitsClient, TypesProduitsClient.TypeProduits, ProduitsClient.Immatriculation, ProduitsClient.Marque, ProduitsClient.Taille, ProduitsClient.Couleur, Clients.Nom, Clients.Prénom FROM Clients" & _
"INNER JOIN (TypesProduitsClient" & _
"INNER JOIN ProduitsClient" & _
"ON TypesProduitsClient.id_TypesProduitsClient = ProduitsClient.id_TypesProduitsClient)" & _
"ON Clients.CodeClient = ProduitsClient.CodeClient;"
Me!lstResults.Requery
End Sub |
Et ce que j'ai fais pour le reste:
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
| Private Sub RefreshQuery()
Dim SQL As String
Dim SQLWhere As String
SQL = "SELECT CodMedia, Titre, Auteur, Famille, Type FROM Medias Where Medias!CodMedia <> 0 "
If Not Me!chkProduit Then
SQL = SQL & "And ProduitsClient!id_TypesProduitsClient like '*" & Me!cmbProduit & "*' "
End If
If Not Me!chkImmatriculation Then
SQL = SQL & "And ProduitsClient!Immatriculation = '" & Me!txtImmatriculation & "' "
End If
If Not Me!chkMarque Then
SQL = SQL & "And ProduitsClient!Marque like '*" & Me!cmbMarque & "*' "
End If
If Not Me!chkTaille Then
SQL = SQL & "And ProduitsClient!Taille like '*" & Me!cmbTaille & "*' "
End If
If Not Me!chkNom Then
SQL = SQL & "And Clients!Nom = '" & Me!txtNom & "' "
End If
If Not Me!chkPrenom Then
SQL = SQL & "And Clients!Prénom = '" & Me!txtPrenom & "' "
End If
SQLWhere = Trim(Right(SQL, Len(SQL) - InStr(SQL, "Where ") - Len("Where ") + 1))
SQL = SQL & ";"
Me!lblStats.Caption = DCount("*", "ProduitsClient", SQLWhere) & " / " & DCount("*", "ProduitsClient")
Me!lstResults.RowSource = SQL
Me!lstResults.Requery |
Tu peux voir que cette ligne n'appelle qu'une seule table.
Me!lblStats.Caption = DCount("*", "ProduitsClient", SQLWhere) & " / " & DCount("*", "ProduitsClient")
Il est surement possible d'appeller n tables mais comment faut il faire...?Je précise que le VBA et moi avons fait connaissance il y a de ça moins d'un mois
Partager