#1 Fri 15 April 2011 10:48
- Soucré
- Participant occasionnel
- Date d'inscription: 12 Nov 2008
- Messages: 40
creation d'un menu pour ajouter des champs
Bonjour,
comment faire pour ajouter des champs a une tables existant avec un Control PopupMenu .
ici un début de code
Include "MapBasic.def"
Include "Menu.def"
Include "Icons.def"
Declare Sub Main
Declare Sub choix
Dim ApplicationPath, champs(20), str,toto as String
Dim i As SmallInt
dim Valeur1,Valeur2,Valeur3 as alias
Dim tata as integer
Sub Main
dialog
title "Ajouter champs"
control statictext position 150,30 width 30 title "CHOIX "
Control StaticText position 10,30 title "CONSOMMATION" Control EditText position 80,30 width 60 id 7
Control PopupMenu Title "Aucun;ALIMENTATION;alcoolise;nonalcool;HABILLEMENT;JOUETS;CHAUSSURES;Ameubledeco;ENTRETIEN;bricojardin;ELECTROMENAGER;AVI;SPORT;loisirsculture;autres"
id 100 value 1 into tata Position 185,30 width 55 Height 40 calling choix
control statictext position 150,60 width 30 title "CHOIX "
Control StaticText position 10,60 title "CONSOMMATION" Control EditText position 80,60 width 60 id 8
Control PopupMenu Title "Aucun;ALIMENTATION;alcoolise;nonalcool;HABILLEMENT;JOUETS;CHAUSSURES;Ameubledeco;ENTRETIEN;bricojardin;ELECTROMENAGER;AVI;SPORT;loisirsculture;autres"
id 100 value 1 into tata Position 185,60 width 55 Height 40 calling choix
Control StaticText position 150,90 width 30 title "CHOIX"
Control StaticText position 10,90 title "CONSOMMATION" Control EditText position 80,90 width 60 id 9
Control PopupMenu Title "Aucun;ALIMENTATION;alcoolise;nonalcool;HABILLEMENT;JOUETS;CHAUSSURES;Ameubledeco;ENTRETIEN;bricojardin;ELECTROMENAGER;AVI;SPORT;loisirsculture;autres"
id 100 value 1 into tata Position 185,90 width 55 Height 40 calling choix
control OKButton Position 100, 180 Width 50 Title "OK"
control CancelButton Position 30, 180 Width 50 Title "Annuler"
if commandinfo(cmd_info_dlg_ok) then
end if
SET PROGRESSBARS ON
End Sub
Sub choix
toto=readcontrolvalue(100)
if toto="1" then alter control 7 value "AUCUN"
elseif toto="2" then alter control 7 value "ALIMENTATION"
elseif toto="3" then alter control 7 value "alcoolise"
elseif toto="4" then alter control 7 value "nonalcool"
'elseif toto="5" then alter control 7 value "HABILLEMENT"
'elseif toto="6" then alter control 7 value "JOUETS"
'elseif toto="7" then alter control 7 value "CHAUSSURES"
'elseif toto="8" then alter control 7 value "Ameubledeco"
'elseif toto="9" then alter control 7 value "ENTRETIEN"
'elseif toto="10" then alter control 7 value "bricojardin"
'elseif toto="11" then alter control 7 value "ELECTROMENAGER"
'elseif toto="12" then alter control 7 value "AVI"
'elseif toto="13" then alter control 7 value "SPORT"
'elseif toto="14" then alter control 7 value "loisirsculture"
'elseif toto="15" then alter control 7 value "autres"
'elseif toto="16" then alter control 7 value "autres2"
'elseif toto="17" then alter control 7 value "autres3"
end if
Alter Table "ma_table" ( add value Integer ) Interactive
'Alter Table "ma_table" ( add value Integer ) Interactive
'Alter Table "ma_table" ( add value Integer ) Interactive
end sub
Hors ligne
#2 Fri 15 April 2011 14:47
- jean94
- Participant assidu
- Date d'inscription: 13 Aug 2009
- Messages: 436
Re: creation d'un menu pour ajouter des champs
Bonjour,
Remplace "Value" dans la ligne ci-dessous par le nom de la colonne
Code:
Alter Table "ma_table" ( add value Integer ) Interactive
Par
Code:
Alter Table "ma_table" ( add ma_colonne Integer ) Interactive
ma_colonne pouvant être remplacée par une variable de type string
JF
Dernière modification par jean94 (Fri 15 April 2011 14:47)
Hors ligne
#3 Mon 18 April 2011 12:16
- Soucré
- Participant occasionnel
- Date d'inscription: 12 Nov 2008
- Messages: 40
Re: creation d'un menu pour ajouter des champs
il me remplis le même choix partout et le message suivant (remplissage_tab2.mb :112) le champs alimentation existe déja.
Include "MapBasic.def"
Include "Menu.def"
Include "Icons.def"
Declare Sub Main
Declare Sub choix
Dim ApplicationPath, champs(20), str,toto as String
Dim i As SmallInt
dim Valeur1,Valeur2,Valeur3 as alias
Dim tata as integer
Sub Main
dialog
title "Ajouter champs"
control statictext position 150,30 width 30 title "CHOIX "
Control StaticText position 10,30 title "CONSOMMATION" Control EditText position 80,30 width 60 id 7
Control PopupMenu Title "Aucun;ALIMENTATION;alcoolise;nonalcool;HABILLEMENT;JOUETS;CHAUSSURES;Ameubledeco;ENTRETIEN;bricojardin;ELECTROMENAGER;AVI;SPORT;loisirsculture;autres"
id 100 value 1 into tata Position 185,30 width 55 Height 40 calling choix
control statictext position 150,60 width 30 title "CHOIX "
Control StaticText position 10,60 title "CONSOMMATION" Control EditText position 80,60 width 60 id 8
Control PopupMenu Title "Aucun;ALIMENTATION;alcoolise;nonalcool;HABILLEMENT;JOUETS;CHAUSSURES;Ameubledeco;ENTRETIEN;bricojardin;ELECTROMENAGER;AVI;SPORT;loisirsculture;autres"
id 100 value 1 into tata Position 185,60 width 55 Height 40 calling choix
Control StaticText position 150,90 width 30 title "CHOIX"
Control StaticText position 10,90 title "CONSOMMATION" Control EditText position 80,90 width 60 id 9
Control PopupMenu Title "Aucun;ALIMENTATION;alcoolise;nonalcool;HABILLEMENT;JOUETS;CHAUSSURES;Ameubledeco;ENTRETIEN;bricojardin;ELECTROMENAGER;AVI;SPORT;loisirsculture;autres"
id 100 value 1 into tata Position 185,90 width 55 Height 40 calling choix
control OKButton Position 100, 180 Width 50 Title "OK"
control CancelButton Position 30, 180 Width 50 Title "Annuler"
if commandinfo(cmd_info_dlg_ok) then
end if
SET PROGRESSBARS ON
End Sub
Sub choix
toto=readcontrolvalue(100)
if toto="1" then alter control 7 value "AUCUN"
elseif toto="2" then alter control 7 value "ALIMENTATION"
elseif toto="3" then alter control 7 value "alcoolise"
elseif toto="4" then alter control 7 value "nonalcool"
elseif toto="5" then alter control 7 value "HABILLEMENT"
elseif toto="6" then alter control 7 value "JOUETS"
elseif toto="7" then alter control 7 value "CHAUSSURES"
elseif toto="8" then alter control 7 value "Ameubledeco"
elseif toto="9" then alter control 7 value "ENTRETIEN"
elseif toto="10" then alter control 7 value "bricojardin"
elseif toto="11" then alter control 7 value "ELECTROMENAGER"
elseif toto="12" then alter control 7 value "AVI"
elseif toto="13" then alter control 7 value "SPORT"
elseif toto="14" then alter control 7 value "loisirsculture"
elseif toto="15" then alter control 7 value "autres"
elseif toto="16" then alter control 7 value "autres2"
elseif toto="17" then alter control 7 value "autres3"
end if
if toto="1" then alter control 8 value "AUCUN"
elseif toto="2" then alter control 8 value "ALIMENTATION"
elseif toto="3" then alter control 8 value "alcoolise"
elseif toto="4" then alter control 8 value "nonalcool"
elseif toto="5" then alter control 8 value "HABILLEMENT"
elseif toto="6" then alter control 8 value "JOUETS"
elseif toto="7" then alter control 8 value "CHAUSSURES"
elseif toto="8" then alter control 8 value "Ameubledeco"
elseif toto="9" then alter control 8 value "ENTRETIEN"
elseif toto="10" then alter control 8 value "bricojardin"
elseif toto="11" then alter control 8 value "ELECTROMENAGER"
elseif toto="12" then alter control 8 value "AVI"
elseif toto="13" then alter control 8 value "SPORT"
elseif toto="14" then alter control 8 value "loisirsculture"
elseif toto="15" then alter control 8 value "autres"
elseif toto="16" then alter control 8 value "autres2"
elseif toto="17" then alter control 8 value "autres3"
end if
if toto="1" then alter control 9 value "AUCUN"
elseif toto="2" then alter control 9 value "ALIMENTATION"
elseif toto="3" then alter control 9 value "alcoolise"
elseif toto="4" then alter control 9 value "nonalcool"
elseif toto="5" then alter control 9 value "HABILLEMENT"
elseif toto="6" then alter control 9 value "JOUETS"
elseif toto="7" then alter control 9 value "CHAUSSURES"
elseif toto="8" then alter control 9 value "Ameubledeco"
elseif toto="9" then alter control 9 value "ENTRETIEN"
elseif toto="10" then alter control 9 value "bricojardin"
elseif toto="11" then alter control 9 value "ELECTROMENAGER"
elseif toto="12" then alter control 9 value "AVI"
elseif toto="13" then alter control 9 value "SPORT"
elseif toto="14" then alter control 9 value "loisirsculture"
elseif toto="15" then alter control 9 value "autres"
elseif toto="16" then alter control 9 value "autres2"
elseif toto="17" then alter control 9 value "autres3"
end if
' ma_table= selto
Alter Table "ma_table" ( add ALIMENTATION Integer ) Interactive
Alter Table "ma_table" ( add alcoolise Integer ) Interactive
Alter Table "ma_table" ( add nonalcool Integer ) Interactive
Alter Table "ma_table" ( add HABILLEMENT Integer ) Interactive
Alter Table "ma_table" ( add JOUETS Integer ) Interactive
Alter Table "ma_table" ( add CHAUSSURES Integer ) Interactive
Alter Table "ma_table" ( add Ameubledeco Integer ) Interactive
Alter Table "ma_table" ( add ENTRETIEN Integer ) Interactive
Alter Table "ma_table" ( add bricojardin Integer ) Interactive
Alter Table "ma_table" ( add ELECTROMENAGER Integer ) Interactive
Alter Table "ma_table" ( add AVI Integer ) Interactive
Alter Table "ma_table" ( add SPORT Integer ) Interactive
Alter Table "ma_table" ( add loisirsculture Integer ) Interactive
Alter Table "ma_table" ( add autres Integer ) Interactive
Alter Table "ma_table" ( add autres2 Integer ) Interactive
Alter Table "ma_table" ( add autres3 Integer ) Interactive
end sub
Hors ligne
#4 Mon 18 April 2011 14:08
- jean94
- Participant assidu
- Date d'inscription: 13 Aug 2009
- Messages: 436
Re: creation d'un menu pour ajouter des champs
Bonjour,
As-tu vérifier si tu avait déja le champ alimentation!
STP quand tu copies ton code sur se forum utilise les balises code.
Merci
JF
Hors ligne
#5 Thu 28 April 2011 11:15
- Soucré
- Participant occasionnel
- Date d'inscription: 12 Nov 2008
- Messages: 40
Re: creation d'un menu pour ajouter des champs
merci ça marche
Hors ligne