Bonjour membres du forum !
J'aimerais utiliser cette fonction pour ramener la modalité dans le champ ModalitePersonnalisse de la table PAYEMENTS.
Voici comment est disposée cette table:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 'Copyright Stephen Lebans 1999 'May not be resold 'Please include my 1 line Copyright notice 'in your code if you use these functions 'I left a bunch of development code in here in case anyone decides to go 'down the same paths I did. 'Created by Stephen Lebans with help from Chris Bergmans ' Updated by Allen Browne Oct/2002 'Production version of GetLineNumberForm 'Works in Form or SubForm mode 'Set controlsource of unbound Text box to '= RowNum([Form]) 'Type exactly as above Public Function RowNum(frm As Form) As Variant On Error GoTo Err_RowNum 'Purpose: Numbering the rows on a form. 'Usage: Text box with ControlSource of: =RowNum([Form]) With frm.RecordsetClone .Bookmark = frm.Bookmark RowNum = .AbsolutePosition + 1 End With Exit_RowNum: Exit Function Err_RowNum: If Err.Number <> 3021& Then 'Ignore "No bookmark" at new row. Debug.Print "RowNum() error " & Err.Number & " - " & Err.Description End If RowNum = Null Resume Exit_RowNum End Function
Et comment j'ai essayé d'adapter le code à mon projet. Je m'excuse pour les erreurs qui s'y trouvent:
Je vous ramène à la discussion https://www.developpez.net/forums/d1...personnalisee/ afin que vous ayez une idée de la démarche recherchée.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 Public Function fnNumLigne(strTable As String, strChamp As String, MaVar As Variant, Anneesco As String, idX As Long) As Long Dim db As DAO.Database Dim rs As DAO.Recordset Set db = CurrentDb Set rs = db.OpenRecordset(strTable, dbOpenDynaset) Dim sql As String strTable = "select * from PAYEMENTS where Anneesco = '" & Anneesco & " and mlepa = " & idX & ";" 'Set rst = db.OpenRecordset(sql) If Not rs.EOF Then ' rs.FindFirst ("[" & strChamp & "] = " & MaVar) fnNumLigne = rs.AbsolutePosition + 1 End If rs.Close Set rs = Nothing db.Close Set db = Nothing End Function
Cordialement.
Partager