Bonjour,
Je fais une requête de sélection sur plusieurs tables mais il se peut que certains champs aient été laissés vide OU que l'enregistrement correspondant au numéro de collection n'existe pas.
Comment faire pour vérifier cela afin de mettre une valeur par défaut nulle dans le formulaire ?
Je vous joins mon code en espérant être assez claire :
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
req_tab_echouage = " SELECT  [x1-TABLE ECHOUAGES].CODE_SEXE,[x1-TABLE ECHOUAGES].ZONE,  [x1-TABLE ECHOUAGES].LONG_CM FROM [x1-TABLE ECHOUAGES] WHERE [x1-TABLE ECHOUAGES].NUM_COLLEC=" & texte_num_collec & ";"
    Set rep = CurrentDb.OpenRecordset(req_tab_echouage)
    If (Not (rep.EOF)) Then
        ' 3) des données ont été trouvées, on les utilise comme valeurs par défaut
        If (rep(0) = 1) Then
            req_statut_repro = "SELECT starem_statrepro_code FROM DATA_Statut_reproducteur_male WHERE starem_num_collec =" & texte_num_collec & ";"
            Set rep2 = CurrentDb.OpenRecordset(req_statut_repro)
            If rep2.EOF Then
                Texte8.DefaultValue = """" & Inconnu & """"
                ' texte8 = statut repro
            Else
                Texte8.DefaultValue = """" & rep2(0) & """"
            ' texte8 = statut repro
                End If
        Else
            If rep(0) <> 0 Then
            req_statut_repro = "SELECT staref_statrepro_code FROM DATA_Statut_reproducteur_femelle WHERE staref_num_collec =" & texte_num_collec & ";"
            Set rep2 = CurrentDb.OpenRecordset(req_statut_repro)
            If rep2.EOF Then
                Texte8.DefaultValue = """" & Inconnu & """"
                ' texte8 = statut repro
            Else
                Texte8.DefaultValue = """" & rep2(0) & """"
            ' texte8 = statut repro
                End If
            End If
            End If
End If
Merci pour votre aide