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
| strSQL = "SELECT T_Patient.NP, T_Patient.CodeIdentifient, T_Patient.Nom, T_Patient.Prénom, T_Patient.Domiciliation, T_Patient.DomDate, T_Patient.DomVal, T_Patient.Note, " & _
"DateDiff(""m"",Now(),[T_Patient].[DatumAbo]) AS Valide, T_Patient.TypeAbo, T_Patient.DatumAbo FROM T_Patient WHERE T_Patient.Domiciliation = -1 And T_Patient.DomVal = -1 " & _
"AND T_Patient.DomDate > Date() And DateDiff(""m"", Now(), [T_Patient].[DatumAbo]) < 0 ORDER BY T_Patient.Nom;"
Dim oRst As DAO.Recordset
Dim oDb As DAO.Database
Set oDb = CurrentDb
Set oRst = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
While Not oRst.EOF
Set oRst2 = oDb2.OpenRecordset("tbl_Factures", dbOpenTable)
Dim strNumFact As String
strNumFact = DLast("[N°Fact]", "tbl_Factures")
strNum = Right(strNumFact, 3)
strNum2 = strNum + 1
Select Case strNum2
Case 1 To 9
strNum2 = "00" & CStr(strNum2)
Case 10 To 99
strNum2 = "0" & CStr(strNum2)
Case 100 To 999
strNum2 = CStr(strNum2)
End Select
strNumFact = Replace(strNumFact, strNum, strNum2)
'Passe en mode Ajout
oRst.AddNew
'Affecte les différents champs
oRst2.Fields("N°Fact").Value = strNumFact
oRst2.Fields("CodeIdentifient").Value = Me.CodeIdentifient
oRst2.Fields("DateFact").Value = Date
'Met à Jour
oRst.Update
oRst.MoveNext
Wend
'Libération des objets
oRst.Close
oDb.Close
Set oRst = Nothing
Set oDb = Nothing |
Partager