Salut a tous
comment mettre dans un combobox les infos d'une base Acces
voici mon code
'============================================
'Procédure de chargement de la feuille
'============================================
Private Sub Form_Load()
Dim Resultat
'Pour relier la connexion ouverte à la commande
CmdVehicule.ActiveConnection = Page_Principale.cnxVehicule
CmdAffectation.ActiveConnection = Page_Principale.cnxVehicule
CmdChauffeur.ActiveConnection = Page_Principale.cnxVehicule
CmdFC.ActiveConnection = Page_Principale.cnxVehicule
'Configuration de la commande avec requete SQL
CmdVehicule.CommandText = "Select * from Fiche"
CmdAffectation.CommandText = " Select * from affectation"
CmdChauffeur.CommandText = "Select * from Chauffeur"
CmdFC.CommandText = "Select * from fiche"
'Initialisation du curseur client
RstVehicule.CursorLocation = adUseClient
RstAffectation.CursorLocation = adUseClient
RstChauffeur.CursorLocation = adUseClient
RstFC.CursorLocation = adUseClient
'Utilisation d'un curseur client dynamique
RstVehicule.CursorType = adOpenDynamic
RstAffectation.CursorType = adOpenDynamic
RstChauffeur.CursorType = adOpenDynamic
RstFC.CursorType = adOpenDynamic
'Vérouillage de l'enregistrement dès son acces
RstVehicule.LockType = adLockPessimistic
RstAffectation.LockType = adLockPessimistic
RstChauffeur.LockType = adLockPessimistic
RstFC.LockType = adLockPessimistic
'Transmission de la commande à la méthode open
RstVehicule.Open CmdVehicule
RstAffectation.Open CmdAffectation
RstChauffeur.Open CmdChauffeur
RstFC.Open CmdFC
'Tri par défaut par Code
RstAffectation.Sort = "Libelle"
RstChauffeur.Sort = "Nom"
' Mise à jour de la listview
ListViewResultat.ListItems.Clear
'Mise à jour de la listView résultat
ListViewResultat.ListItems.Clear
ListViewResultat.ColumnHeaders.Add , , "Code", (ListViewResultat.Width * (0.84 / 2)), lvwColumnLeft
ListViewResultat.ColumnHeaders.Add , , "Immatriculation", (ListViewResultat.Width * (0.96 / 2)), lvwColumnCenter
ListViewResultat.View = lvwReport
'LA PREMIERE FONCTIONNE BIEN MAIS PAS LA 2EME'Pour remplir la combobox genre
CmdVehicule.CommandText = "Select Distinc Genre from Fiche"
RstVehicule.Sort = "Genre asc"
RstVehicule.Requery
Do Until RstVehicule.EOF
Genre.AddItem RstVehicule!Genre
RstVehicule.MoveNext
Loop
Genre.ListIndex = -1
'
'Pour remplir la combobox marque
CmdVehicule.CommandText ="Select Distinct Marque from Fiche"
RstVehicule.Sort="Marque asc"
RstVehicule.Requery
Do Until RstVehicule.EOF
Marque.AddItem RstVehicule!Marque
RstVehicule.MoveNext
Loop
Marque.ListIndex = -1
'verrouiller les boutons commandes
Supprimer.Enabled = False
Sauvegarder.Visible = False
TextRecherche_Change
RstVehicule.MoveFirst
Fiche_Vehicule.Caption = " Véhicule N° : " & RstVehicule!immatriculation
End Sub
Merci pour vos reponses