Récupérer le nom d'un champs / colonne en fonction Access

mladenski Messages postés 12 Date d'inscription samedi 15 novembre 2008 Statut Membre Dernière intervention 24 avril 2009 - 24 avril 2009 à 14:30
mladenski Messages postés 12 Date d'inscription samedi 15 novembre 2008 Statut Membre Dernière intervention 24 avril 2009 - 24 avril 2009 à 14:38
Bonjour.
J'ai une table qui contient plusieurs champs de prix. J'ai crée une première fonction qui affiche le prix minimum de ces champs. Une 2ème fonction récupère le nom du champs où se trouve le minimum. Pour l'nstant, je rentre en dur le nom des champs dans la 2ème fonction mais j'aimerais que ça soit fait autrement. Je veux récupérer le nom du champs et le stocker dans une variable mais je n'arrive pas à le faire. Est-ce que quelqu'un pourrait m'aider, S.V.P.

<colgroup><col style=\"WIDTH: 60pt\" width=\"80\" /><col style=\"WIDTH: 60pt\" span=\"5\" width=\"80\" /><col style=\"WIDTH: 62pt; mso-width-source: userset; mso-width-alt: 2998\" width=\"82\" /></colgroup>----
, Société A, Société B, Société C, Société D, Prix Min, Société Min, ----
Opération 1, 5 €, 7 €, 4 €, 1 €, 1 €, Société D, ----
Opération 2, 22 €, 48 €, 54 €, 17 €, 17 €, Société D, ----
Opération 3, 13 €, 18 €, 22 €, 23 €, 13 €, Société A, ----
Opération 4, 109 €, 108 €, 209 €, 219 €, 108 €, Société B

1 réponse

mladenski Messages postés 12 Date d'inscription samedi 15 novembre 2008 Statut Membre Dernière intervention 24 avril 2009
24 avril 2009 à 14:38
Voici la fonction que je veux modifier (en rouge --> je veux récupérer les noms des colonnes et ne pas les rentrer en dur):
Public FunctionChampsMin(ParamArray LesVariables() As Variant)<?xml:namespace prefix o ns "urn:schemas-microsoft-com:office:office" /??>

 

Dim intVar As Integer

Dim varMinTab As Double

Dim i, j As Integer

Dim TabNoms

 

TabNoms = Null

TabNoms = Array("Société 1", " Société 2", " Société 3", "Société 4", " Société 5", " Société 6", " Société 7", " Société 8", " Société 9")

 

varMinTab = LesVariables(0)

i = 0

j = 0

For intVar = 1 To UBound(LesVariables())

 

    If LesVariables(intVar) = 0 Or LesVariables(intVar) > varMinTab Then

        j = j + 1

    End If

   

        If LesVariables(intVar) < varMinTab And LesVariables(intVar) <> 0 Then

            i = i + j + 1

            varMinTab = LesVariables(intVar)

            j = 0

        End If

       

Next intVar

 

ChampsMin = TabNoms(i)

End Function
0
Rejoignez-nous