Bonjour à tous,
J’essaie de faire fonctionner un code pris sur la FAQ mais je n’y arrive pas entièrement. En fait il s’agit de rétablir la liaison des tables avec le VBA Dorsale/Fontale
La liaison des tables se fait sans souci particulier.
Code progressBar:
End Sub
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
36
37
38
39
40 Private Sub Form_Timer() lngProg = lngProg + 1 ProgressBar.Width = Int(lngProg * Bar.Width / 100) ProgressDroite.Caption = lngProg & " %" If ProgressBar.Width + ProgressBar.Left >= ProgressGauche.Left Then ProgressGauche.Visible = True ProgressGauche.Width = (ProgressBar.Width + _ ProgressBar.Left) - ProgressGauche.Left ProgressGauche.Caption = lngProg & " %" End If DoCmd.RepaintObject acForm, Me.Name If lngProg = 100 Then TimerInterval = 0: lngProg = 0 'btnTest.Caption = "&Lancer le test de la barre" 'remise à zéro du temps pour la minuterie Me.TimerInterval = 0 'Test si la bdd à bouger en testant le chemin de liaison des tables If Not (GetLinkedDBName("tblAdherents") = CurrentProject.Path & "\Serveur\Data Gestion des Syndiqués.mdb") Then 'Appel Fonction permettant de lier les tables If LierTables(CurrentProject.Path & "\Données\Data Gestion des Syndiqués.mdb") = False Then GoTo err_Maj 'Appel Fonction permettant de mettre à jour le chemin des images If MAJ_Photos(CurrentProject.Path & "\Photos\", "tblAdherents", "AdhPhoto") = False Then GoTo err_Maj 'Répertoire d'installation des photos 'strRepertoirePhotos = strRepertoirePhotos & "Photos\" 'message ok MsgBox "Vous êtes connecté à Gestion des Syndiqués", , "Connection" 'End If 'Fermeture du Splash DoCmd.Close 'Ouverture Formulaire DoCmd.OpenForm "frmAdherents" Exit Sub err_Maj: MsgBox "Une erreur c'est produite pendant la mise à jour des tables et de images", vbExclamation, "Mise à jour" DoCmd.Close DoCmd.OpenForm "frmPassword" End If End If
Mon problème réside sur l’affichage des photos dans mon formulaire ainsi que la fonction insérer photos.
Message d’erreur Affichage photo : Une fois les liaisons rétablies la photo qui était présente dans le champ photo s’affiche normalement, en revanche quand je passe à l’enregistrement suivant et que le champ photo est vide il devrait m’afficher la photo Blank.jpg, or là le message suivant s’affiche : Erreur d’exécution 2220 Microsoft Access ne peut pas ouvrir le fichier Blank.jpg
Code affichage photo :
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 Private Sub Form_Current() 'Affichage de la photo et de son libellé - Gestion d'erreurs If IsNull(Me.AdhPhoto.value) Then Me.Image21.Picture = strRepertoirePhotos & "Blank.jpg" 'Me.LibellePhoto = "Photo non disponible" Else Me.Image21.Picture = strRepertoirePhotos & Me.AdhPhoto.value 'Me.LibellePhoto = Left(Me.AdhPhoto.value, InStr(Me.AdhPhoto.value, ".") - 1) End If Exit Sub GestionErreur: Select Case Err.Number Case 2114 'Cas d'un type de fichier photo non supporté MsgBox "Le format de l'image n'est supporté par le contrôle image ", vbCritical + vbOKOnly, "Essai EPI" Me.Image21.Picture = strRepertoirePhotos & "Blank.jpg" 'Me.LibellePhoto = "Photo non disponible" Case 2220 'Cas d'un emplacement non valide du fichier image MsgBox "Le fichier image n'a pas été trouvé à l'emplacement indiqué : " & vbCrLf & _ Me.AdhPhoto.value, vbCritical + vbOKOnly, " Me.Image21.Picture = strRepertoirePhotos & "Blank.jpg" 'Me.LibellePhoto = "Photo non disponible" Case Else ' tout autre cas d'erreur MsgBox "Erreur inattendue : " & Err.Number & vbCrLf & Err.Description, vbCritical + vbOKOnly, "" End Select Err.Clea End Sub
Quand à la fonction insérer photo le message suivant : Erreur de compilation Type d’argument ByRef incompatible
Code function :
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 Function InsererPhoto() '-------------------------------------------------------------------------------------------- ' Projet : Gestion des photos ' Appel : ' Auteur : Domi2 ' Version : 1.0 - 26.07.2007 ' Révision : - ' Commentaires : Permet d'enregistrer le nom de la photo dans la table ' Lien : '-------------------------------------------------------------------------------------------- 'Ouverture de la boîte de dialogue Ouvrir fichier. On ne récupère que le nom du fichier. 'Paramètre : 1 pour récupérer le nom du chemin complet 'Paramètre : 2 pour récupérer uniquement le nom de fichier NomPhoto = OuvrirFichier(Me.hwnd, "Choisir une photo pour cet Adhérent", 2, "Fichier .jpg", "jpg", strRepertoirePhotos) 'Récupération et stockage du chemin du fichier dans le champ PlongeePhoto If NomPhoto <> "" Then Me.AdhPhoto.value = NomPhoto Else Exit Function End If 'Affichage de la photo Me.Image21.Picture = strRepertoirePhotos & Me.AdhPhoto.value 'Modification du libellé de la photo 'Me.LibellePhoto = Left(Me.AdhPhoto.value, InStr(Me.AdhPhoto.value, ".") - 1) 'End Select End Function
Si quelqu'un peut m'aider à y voir plus clair
Merci
Partager