Code VBA pour bouton de commande
Bonjour,
Est ce que quelqu'un peut m'expliquer le code ci dessous, car je débute avec Access 2007, et là sur le code, je sais qu'il y a juste une déclaration de variable "StrSql" mais je ne comprends pas le raisonnement qui a été fait:
Code:
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 48 49 50 51 52 53 54 55 56
| Private Sub bcRecalculer_Click()
On Error GoTo Err_bcRecalculer_Click
Dim StrSql As String
StrSql = ""
StrSql = StrSql & "SELECT "
StrSql = StrSql & "1 AS Comptage, "
StrSql = StrSql & "Promo_Identite.Code As CodePromo, "
StrSql = StrSql & "Stage_Identite.Attestation_Assusrance, "
StrSql = StrSql & "[Etudiant_Identite].[Nom] & ' - ' & [Etudiant_Identite].[Prenom] AS Etudiant, "
StrSql = StrSql & "[Etudiant_Identite].[Telephone] AS TelEtudiant, "
StrSql = StrSql & "[IUT_Tuteur_Identite].[Nom] & ' - ' & [IUT_Tuteur_Identite].[Prenom] AS Iut_Tuteur, "
StrSql = StrSql & "[IUT_Tuteur_Identite].[Telephone] AS TelIutTuteur, "
StrSql = StrSql & "Entreprise_Identite.RaisonSociale, "
StrSql = StrSql & "ActiviteGroupe_Identite.Libelle AS LibActivite, "
StrSql = StrSql & "Fourchette_NombreSalarie.Libelle AS Nb_Salarie "
StrSql = StrSql & "FROM "
StrSql = StrSql & "(Etudiant_Identite "
StrSql = StrSql & "INNER JOIN (Fourchette_NombreSalarie "
StrSql = StrSql & "INNER JOIN (ActiviteGroupe_Identite "
StrSql = StrSql & "INNER JOIN (Entreprise_Identite "
StrSql = StrSql & "INNER JOIN (IUT_Tuteur_Identite "
StrSql = StrSql & "INNER JOIN Stage_Identite "
StrSql = StrSql & "ON IUT_Tuteur_Identite.Id = Stage_Identite.IUT_Tuteur) "
StrSql = StrSql & "ON Entreprise_Identite.Id = Stage_Identite.Entreprise_Id) "
StrSql = StrSql & "ON ActiviteGroupe_Identite.Id = Entreprise_Identite.SecteurActiviteGroupe) "
StrSql = StrSql & "ON Fourchette_NombreSalarie.Id = Entreprise_Identite.NombreSalarie) "
StrSql = StrSql & "ON Etudiant_Identite.Id = Stage_Identite.Etudiant_Id) "
StrSql = StrSql & "INNER JOIN Promo_Identite ON Stage_Identite.Promo = Promo_Identite.Id "
StrSql = StrSql & "WHERE ("
StrSql = StrSql & "(1=1) "
If Sel_Promo <> 0 Then StrSql = StrSql & " And ((Stage_Identite.Promo)= " & Sel_Promo & ") "
If sel_AssuranceAttestation <> 1 Then StrSql = StrSql & " And ((Stage_Identite.Attestation_Assusrance)= " & sel_AssuranceAttestation & ") "
If Sel_IutStagiaire <> 0 Then StrSql = StrSql & " And ((Etudiant_Identite.Id)= " & Sel_IutStagiaire & ") "
If Sel_IutStagiaire <> 0 Then StrSql = StrSql & " And ((Etudiant_Identite.Id)= " & Sel_IutStagiaire & ") "
If Sel_IutTuteur <> 0 Then StrSql = StrSql & " And ((IUT_Tuteur_Identite.Id)= " & Sel_IutTuteur & ") "
If Sel_EntrepriseIdentite <> 0 Then StrSql = StrSql & " And ((Entreprise_Identite.Id)= " & Sel_EntrepriseIdentite & ") "
If Sel_EntrepriseActivite <> 0 Then StrSql = StrSql & " And ((ActiviteGroupe_Identite.Id)= " & Sel_EntrepriseActivite & ") "
If Sel_EntrepriseNbSalarie <> 0 Then StrSql = StrSql & " And ((Fourchette_NombreSalarie.Id)= " & Sel_EntrepriseNbSalarie & ")"
If Sel_EntrepriseTuteur <> 0 Then StrSql = StrSql & " And ((Select Count(*) From Entreprise_Acteur Where Entreprise = Entreprise_Identite.Id And Entreprise_Acteur.Id= " & Sel_EntrepriseTuteur & ") > 0 ) "
StrSql = StrSql & ");"
If Not Me.Section(0).Visible Then Me.Section(0).Visible = True
Me.RecordSource = StrSql
Exit_bcRecalculer_Click:
Exit Sub
Err_bcRecalculer_Click:
MsgBox Err.Description
Resume Exit_bcRecalculer_Click |
MERCI D'AVANCE POUR VOTRE AIDE! car c'est dur le commencement avec Access, surtout quand on n'y connait pas trop en programmation...^^