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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
Public Function FctRechercheDroitsFicheIncident( _
ByVal StrDroits As String, _
ByVal StrRegion As String, _
ByVal StrStatut As String, _
ByVal StrUser As String) As Boolean
Dim SQL As String
Dim SQLRegion As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim LngIndex As Long
On Error GoTo ErrHandler
FctRechercheDroitsFicheIncident = False
SQL = "SELECT Incident.NumIncident, Incident.Typologie, Incident.NumSite, Incident.DatIncident, Incident.NomRedacteur, Incident.TypIncident, Incident.MatIncident, Incident.EquipIncident, Incident.DatAnalyseNational, Incident.ResponsableAnalyse, Incident.OuvertLe, Incident.ClosLe, Incident.ClosPar, Incident.CompteRendu, Incident.MesuresSecurisationIntermédiaires, Incident.DateAnalyse, Incident.ResultatAnalyse, Incident.ChefDeProjetRegional, Incident.ChefDeProjetNational, Incident.Statut" & _
" FROM ((Region INNER JOIN Ville ON Region.NomRegion = Ville.Region) INNER JOIN (Site INNER JOIN Incident ON Site.Site = Incident.NumSite) ON Ville.Ville = Site.Ville) INNER JOIN Login ON Region.NomRegion = Login.Region" '& _
" WHERE Incident.NumIncident='" & Form_FrmListeDesIncidents.LstResultQuery.ItemsSelected(0)
If StrDroits <> CstAdmin Then
If StrRegion = "NAT" Then
'Si le code région est : "National"
SQL = SQL & " WHERE (((Incident.Statut)='" & "Public" & "'))"
' SQL = SQL & " AND (((Incident.Statut)='" & "Public" & "'))"
Else
'Sinon : c'est une des 6 régions
SQL = SQL & " WHERE (((Incident.Statut)='" & "Public" & "')) OR (((Region.NomRegion)='" & StrRegion & "'))"
' SQL = SQL & " AND (((Incident.Statut)='" & "Public" & "')) OR (((Region.NomRegion)='" & StrRegion & "'))"
SQLRegion = "SELECT Site.Site, Ville.Ville, Region.NomRegion" & _
" FROM (Region INNER JOIN Ville ON Region.NomRegion = Ville.Region) INNER JOIN Site ON Ville.Ville = Site.Ville" & _
" WHERE (((Region.NomRegion)='" & StrRegion & "'));"
End If
Else
End If
SQL = SQL & " ;"
Set db = DBEngine.Workspaces(0).Databases(0)
Set rs = db.OpenRecordset(SQL, DB_OPEN_DYNASET)
'===> La partie qui m'intéresse est ici...
If Not rs.NoMatch Then
Form_FrmFormulaireIncident.RecordSource = SQL
' If Trim(SQLRegion) <> "" Then
Form_FrmFormulaireIncident.NumSite.RowSourceType = "Table/Query"
Form_FrmFormulaireIncident.NumSite.RowSource = ReqLocalisationRegion 'SQLRegion
' Set rs = Nothing
' Set rs = db.OpenRecordset(SQLRegion, DB_OPEN_DYNASET)
' Set Form_FrmFormulaireIncident.NumSite.Recordset = rs
Form_FrmFormulaireIncident.Requery
' End If
Else
Err.Description = "Aucun incident ne correspond aux critères sélectionnés"
Err.Raise 1
End If
FctRechercheDroitsFicheIncident = True
ExitHandler:
Set rs = Nothing
Set db = Nothing
Exit Function
ErrHandler:
Resume
MsgBox Err.Description, vbExclamation, CstAppName
FctRechercheDroitsFicheIncident = False
Resume ExitHandler
End Function |
Partager