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
| Public Function fctMajNbSousLoc(ByVal Parent)
Dim combien As Long, SQL As String
Select Case Len(Parent)
Case 1
combien = DCount("MagasinID", "tblMagasin", "DepotParent = '" & Parent & "'")
'Debug.Print "combien1 " & combien
'DoCmd.RunSQL "UPDATE tblDepot SET NbSousLoc = " & combien & " WHERE DepotID = '" & Parent & "' ;"
SQL = "UPDATE tblDepot SET NbSousLoc = " & combien & " WHERE DepotID = '" & Parent & "' WITH OWNERACCESS OPTION;"
Case 2
combien = DCount("EpiID", "tblEpi", "MagasinParent = '" & Parent & "'")
'Debug.Print "combien2 " & combien
SQL = "UPDATE tblMagasin SET NbSousLoc = " & combien & " WHERE MagasinID = '" & Parent & "' WITH OWNERACCESS OPTION;"
Case 3
combien = DCount("TraveeID", "tblTravee", "EpiParent = '" & Parent & "'")
'Debug.Print "combien3 " & combien
SQL = "UPDATE tblEpi SET NbSousLoc = " & combien & " WHERE EpiID = '" & Parent & "' WITH OWNERACCESS OPTION;"
Case 4
combien = DCount("TabletteID", "tblTablette", "TraveeParent = '" & Parent & "'")
'Debug.Print "combien4 " & combien
SQL = "UPDATE tblTravee SET NbSousLoc = " & combien & " WHERE TraveeID = '" & Parent & "' WITH OWNERACCESS OPTION;"
Case 5
combien = DCount("ArticleID", "tblArticle", "AdTopo = '" & Parent & "'")
'Debug.Print "combien5 " & combien
SQL = "UPDATE tblTablette SET NbSousLoc = " & combien & " WHERE TabletteID = '" & Parent & "' WITH OWNERACCESS OPTION;"
Case Else
MsgBox "Cas non prévu ", , "xxx"
End Select
CurrentDb.QueryDefs("qryMajNbSousLoc").SQL = SQL
End Function |
Partager