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
| Private Sub Cmd_Remplissage_Click()
Dim db As Database
Dim rs1 As Recordset
Dim rs2 As Recordset
Dim i, a, b As Variant
Dim MyString As Variant
Dim MyPrefix As Variant
Dim tt As String
'ouverture de la table Avancement
Set rs1 = CurrentDb.OpenRecordset("Avancement")
'ouverture de la table prefixe
Set rs2 = CurrentDb.OpenRecordset("Prefixe")
'fabrication des chaines de caractère
'mystring =extraire de la table Avancement le nom sondage ayant la clef=i
'boucle pour ecriture
a = DMin("[clef]", "Avancement")
b = DMax("[clef]", "Avancement")
For i = a To b
MyString = DLookup("[holeID]", "Avancement", "[clef]=" & i)
'condition d'existence
If Mid(MyString,3,1)="_" Then
MyPrefix = DLookup("[pref_ser]", "prefixe", "[pref_org]='" & Left(MyString, 2) & "'")
tt = "S" & MyPrefix & Mid(MyString, 4, 4) & Right(MyString, 1) & "AVAN.M"
Else
MyPrefix = DLookup("[pref_ser]", "prefixe", "[pref_org]='" & Left(MyString, 4) & "'")
tt = "S" & MyPrefix & Mid(MyString, 6, 4) & Right(MyString, 1) & "AVAN.M"
End If
'clé primaire
rs1.Index = "primarykey"
'recherche dans la colonne clef un champ égal à i
rs1.Seek "=", i
'mode édition
rs1.Edit
'ecriture champ tt
rs1.Fields("holeID") = tt
'mise a jour
rs1.Update
Next i
End Sub |
Partager