Bonjour
Mon application est constituer d'une form MDIForm et de plusieurs form MDIChild ainsi que de quelques forms de type normal .l'un des forms MDIChild contient un tableau DBGrid et un button "modifier" qui ouvre une form de type normal qui charge (OnCreateForm) les données d'un enregistrement selectionner dans DBGrid afin de les modifier.
au debut ,ca marche bien
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 procedure Tfrmodif.FormCreate(Sender: TObject); begin Edit1.Text:=Form2.TA1.fieldbyName('codecli').asstring; Edit2.Text:=Form2.TA1.fieldbyName('nom').asstring; Edit3.Text:=Form2.TA1.fieldbyName('prenom').asstring; Edit4.Text:=Form2.TA1.fieldbyName('adresse').asstring; Edit5.Text:=Form2.TA1.fieldbyName('ville').asstring; Maskedit1.Text:=Form2.TA1.fieldbyName('tel').asstring; end;
mais depuis que j modifier le code d'ouverture des form MDIChild afin d'avoir qu'une seule instance (code trouvé ici dans le forum):
lorsque je clic sur "modifier" une erreur " violation d'accée..." se produit!!
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 procedure TForm1.OuvertureFiche(Class_Fiche: TFormClass); var Num_Fiche : integer; trouve_Fiche : Boolean; begin trouve_Fiche := false; Num_Fiche := 0; while (Not trouve_Fiche) and (Num_Fiche<Screen.FormCount) do begin if (Screen.Forms[Num_Fiche] is Class_Fiche) then begin if Not (csDestroying in Screen.Forms[Num_Fiche].ComponentState) then Screen.Forms[Num_Fiche].Show; trouve_Fiche := true; break; end; Inc(Num_Fiche); end; if Not trouve_Fiche then with Class_Fiche.Create(Self) do show; end;.
merci d'avance![]()
Partager