Access vb

otareed Messages postés 4 Date d'inscription vendredi 12 mars 2010 Statut Membre Dernière intervention 29 octobre 2010 - 26 oct. 2010 à 13:34
otareed Messages postés 4 Date d'inscription vendredi 12 mars 2010 Statut Membre Dernière intervention 29 octobre 2010 - 29 oct. 2010 à 20:31
salut
svp je viens de faire une base de donnée simple ;mon but est de savoir lié une interface graphique de vb.net 2008 et cette base de données ;autrement dit je ve savoir comment coder le buttons ( les etapes s il st disponibles)et merci

8 réponses

cs_Jack Messages postés 14006 Date d'inscription samedi 29 décembre 2001 Statut Modérateur Dernière intervention 28 août 2015 79
26 oct. 2010 à 15:18
Salut et bienvenu

Le plus simple est de commencer par le début : la recherche.
Tape simplement "access" dans la recherche de codes en .Net et tu auras des exemples.

Vala
Jack, MVP VB
NB : Je ne répondrai pas aux messages privés

Le savoir est la seule matière qui s'accroit quand on la partage (Socrate)
0
vblover Messages postés 57 Date d'inscription mardi 25 février 2003 Statut Membre Dernière intervention 27 janvier 2011
27 oct. 2010 à 05:05
donne un peu plus d'info sur ta bd (access, sql ou quoi?)


vblover
0
cs_Jack Messages postés 14006 Date d'inscription samedi 29 décembre 2001 Statut Modérateur Dernière intervention 28 août 2015 79
27 oct. 2010 à 08:43
Désolé, nous ne donnons pas de cours particuliers.
Si tu cherches des infos, c'est à toi de les chercher.
Les codes déposés ici sont là pour te montrer comment faire. A toi d'analyser, de regarder les méthodes, les options, d'adapter à tes besoins, de faire des essais, etc ...
0
otareed Messages postés 4 Date d'inscription vendredi 12 mars 2010 Statut Membre Dernière intervention 29 octobre 2010
27 oct. 2010 à 22:46
merci les amis , j effectuer une base de donnée access et j' ai fé une interface graphique qui des button ajouter supprimer enregistrer ,je ve savoir comment coder ces bottons ( base de donnée contien une gestion des eleves nom prénom age ) j ai fé la liaison vb access ,mais je me suis arreté au niveau des button ,et merci pr vos aides
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
vblover Messages postés 57 Date d'inscription mardi 25 février 2003 Statut Membre Dernière intervention 27 janvier 2011
28 oct. 2010 à 18:36
voila une form vb 6.0 essaie de t'inspirer. Si tu as besoin de vb.net (2005) j'ai l'equivallent de ce linsting.

VERSION 5.00
Begin VB.Form frmclients
BorderStyle = 3 'Fixed Dialog
Caption = "clients"
ClientHeight = 4845
ClientLeft = 45
ClientTop = 330
ClientWidth = 6060
ControlBox = 0 'False
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4845
ScaleWidth = 6060
ShowInTaskbar = 0 'False
StartUpPosition = 1 'CenterOwner
Tag = "clients"
Begin VB.CommandButton CmdQuitter
Caption = "&Quitter"
Height = 495
Left = 2400
TabIndex = 24
Top = 3840
Width = 975
End
Begin VB.TextBox Txtsolde
DataField = "solde"
DataSource = "Data1"
Height = 285
Left = 2040
TabIndex = 23
Top = 3000
Width = 2535
End
Begin VB.ComboBox Combo1
DataField = "client type"
DataSource = "Data1"
Height = 315
Left = 2040
TabIndex = 21
Text = "Combo1"
Top = 2640
Width = 2775
End
Begin VB.CommandButton cmdGrid
Caption = "&Grille"
Height = 540
Left = 4800
TabIndex = 20
Tag = "&Grille"
Top = 3840
Width = 975
End
Begin VB.CommandButton cmdUpdate
Caption = "&Mettre à jour"
Height = 540
Left = 3720
TabIndex = 19
Tag = "&Mettre à jour"
Top = 3840
Width = 975
End
Begin VB.CommandButton cmdDelete
Caption = "&Supprimer"
Height = 540
Left = 1200
TabIndex = 18
Tag = "&Supprimer"
Top = 3840
Width = 975
End
Begin VB.CommandButton cmdAdd
Caption = "&Ajouter"
Height = 540
Left = 120
TabIndex = 17
Tag = "&Ajouter"
Top = 3840
Width = 975
End
Begin VB.Data Data1
Align = 2 'Align Bottom
Connect = "Access"
DatabaseName = ""
DefaultCursorType= 0 'DefaultCursor
DefaultType = 2 'UseODBC
Exclusive = 0 'False
Height = 345
Left = 0
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 4500
Width = 6060
End
Begin VB.TextBox txtFields
DataField = "telephone"
DataSource = "Data1"
Height = 285
Index = 7
Left = 2040
MaxLength = 15
TabIndex = 15
Top = 2280
Width = 3375
End
Begin VB.TextBox txtFields
DataField = "matricule fiscal"
DataSource = "Data1"
Height = 285
Index = 6
Left = 2040
MaxLength = 15
TabIndex = 13
Top = 1960
Width = 3375
End
Begin VB.TextBox txtFields
DataField = "article imposition"
DataSource = "Data1"
Height = 285
Index = 5
Left = 2040
MaxLength = 15
TabIndex = 11
Top = 1640
Width = 3375
End
Begin VB.TextBox txtFields
DataField = "registre de commerce"
DataSource = "Data1"
Height = 285
Index = 4
Left = 2040
MaxLength = 15
TabIndex = 9
Top = 1320
Width = 3375
End
Begin VB.TextBox txtFields
DataField = "ville"
DataSource = "Data1"
Height = 285
Index = 3
Left = 2040
MaxLength = 15
TabIndex = 7
Top = 1000
Width = 3375
End
Begin VB.TextBox txtFields
DataField = "adresse"
DataSource = "Data1"
Height = 285
Index = 2
Left = 2040
MaxLength = 25
TabIndex = 5
Top = 680
Width = 3375
End
Begin VB.TextBox txtFields
DataField = "nom client"
DataSource = "Data1"
Height = 285
Index = 1
Left = 2040
MaxLength = 25
TabIndex = 3
Top = 360
Width = 3375
End
Begin VB.TextBox txtFields
DataField = "code client"
DataSource = "Data1"
Enabled = 0 'False
Height = 285
Index = 0
Left = 2040
TabIndex = 1
Top = 40
Width = 1935
End
Begin VB.Label Label1
Caption = "solde"
Height = 255
Left = 120
TabIndex = 22
Top = 3000
Width = 1815
End
Begin VB.Label lblLabels
Caption = "client type:"
Height = 255
Index = 8
Left = 120
TabIndex = 16
Tag = "client type:"
Top = 2620
Width = 1815
End
Begin VB.Label lblLabels
Caption = "telephone:"
Height = 255
Index = 7
Left = 120
TabIndex = 14
Tag = "telephone:"
Top = 2300
Width = 1815
End
Begin VB.Label lblLabels
Caption = "matricule fiscal:"
Height = 255
Index = 6
Left = 120
TabIndex = 12
Tag = "matricule fiscal:"
Top = 1980
Width = 1815
End
Begin VB.Label lblLabels
Caption = "article imposition:"
Height = 255
Index = 5
Left = 120
TabIndex = 10
Tag = "article imposition:"
Top = 1660
Width = 1815
End
Begin VB.Label lblLabels
Caption = "registre de commerce:"
Height = 255
Index = 4
Left = 120
TabIndex = 8
Tag = "registre de commerce:"
Top = 1340
Width = 1815
End
Begin VB.Label lblLabels
Caption = "ville:"
Height = 255
Index = 3
Left = 120
TabIndex = 6
Tag = "ville:"
Top = 1020
Width = 1815
End
Begin VB.Label lblLabels
Caption = "adresse:"
Height = 255
Index = 2
Left = 120
TabIndex = 4
Tag = "adresse:"
Top = 700
Width = 1815
End
Begin VB.Label lblLabels
Caption = "nom client:"
Height = 255
Index = 1
Left = 120
TabIndex = 2
Tag = "nom client:"
Top = 380
Width = 1815
End
Begin VB.Label lblLabels
Caption = "code client:"
Height = 255
Index = 0
Left = 120
TabIndex = 0
Tag = "code client:"
Top = 60
Width = 1815
End
End
Attribute VB_Name = "frmclients"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub cmdAdd_Click()

cmdAdd.Enabled = False
cmdDelete.Enabled = False
Data1.Recordset.AddNew
Txtfields(1).SetFocus
Txtsolde.Text = 0
Combo1.Text = "PUBLIC"

End Sub


Private Sub cmdDelete_Click()
Dim reponse As Integer
Dim Bl_OldEfface As Boolean

If Data1.Recordset.Fields("solde") <> 0 Then
reponse = MsgBox("Client avec solde different de zero", vbOKOnly + vbCritical)
Exit Sub
End If
With Data1.Recordset
Bl_OldEfface = .Fields("efface")
.Edit
.Fields("efface") = Not (.Fields("efface"))
If Bl_OldEfface Then
cmdDelete.Caption = "&Supprimer"
Txtfields(0).BackColor = vbGreen
Else
cmdDelete.Caption = "&Restaurer"
Txtfields(0).BackColor = vbRed
End If
.Update
End With

End Sub


Private Sub cmdRefresh_Click()

'ceci est en fait uniquement nécessaire pour les applications multiutilisateur
Data1.Refresh

End Sub


Private Sub CmdQuitter_Click()

Unload Me

End Sub


Private Sub cmdUpdate_Click()

Data1.UpdateRecord
Data1.Recordset.bookmark = Data1.Recordset.LastModified
Glng_CodeAddedClient = Data1.Recordset.Fields("code client")
cmdAdd.Enabled = True
cmdDelete.Enabled = True

End Sub


Private Sub cmdGrid_Click()

On Error GoTo cmdGrid_ClickErr
Dim f As New frmDataGrid
f.Command1.Visible = False
f.Command2.Visible = False
Set f.Data1.Recordset = Data1.Recordset
f.Caption = Me.Caption & " Grid"
f.Show 1
Exit Sub
cmdGrid_ClickErr:

End Sub


Private Sub Data1_Error(DataErr As Integer, _
Response As Integer)

'C'est l'emplacement où mettre le code de gestion d'erreur
'Si vous voulez ignorer les erreurs, mettez la ligne qui suit en commentaire
'Si vous souhaitez les intercepter, ajoutez du code ici pour les gérer
MsgBox "Data erreur:" & error$(DataErr)
Response = 0'Débarassez-vous de l'erreur

End Sub


Private Sub Data1_Reposition()
Dim Bl_OldEfface As Boolean

Screen.MousePointer = vbDefault
On Error Resume Next
Data1.Caption = " Enregistrement: " & (Data1.Recordset.AbsolutePosition + 1) & "/" & Str(Data1.Recordset.RecordCount)
With Data1.Recordset
Bl_OldEfface = .Fields("efface")
If Bl_OldEfface Then
cmdDelete.Caption = "&Restaurer"
Txtfields(0).BackColor = vbRed
Else
cmdDelete.Caption = "&Supprimer"
Txtfields(0).BackColor = vbGreen
End If
End With

End Sub


Private Sub Data1_Validate(Action As Integer, _
Save As Integer)

'Insérez ici le code de validation
'Cet événement est appelé lorsque les actions suivantes se produisent
Select Case Action
Case vbDataActionMoveFirst
Case vbDataActionMovePrevious
Case vbDataActionMoveNext
Case vbDataActionMoveLast
Case vbDataActionAddNew
Case vbDataActionUpdate
Case vbDataActionDelete
Case vbDataActionFind
Case vbDataActionBookmark
Case vbDataActionClose
Screen.MousePointer = vbDefault
End Select
Screen.MousePointer = vbHourglass

End Sub


Private Sub Form_Load()
Dim reponse As Boolean
Dim sqlclient As String

reponse = feuillecentree(Me)
Data1.DatabaseName = Gstr_BaseFixe
sqlclient = "select * from clients order by [nom client],[ville]"
Set Data1.Recordset = MdBase.OpenRecordset(sqlclient)
If Data1.Recordset.RecordCount = 0 Then
Data1.Recordset.AddNew
End If
Combo1.AddItem "PUBLIC"
Combo1.AddItem "DETAILLANT"
Combo1.AddItem "REVENDEUR"
Combo1.AddItem "GROSSISTE"
Txtsolde.Enabled = False

End Sub


Private Sub Form_Unload(Cancel As Integer)

If Data1.Recordset.RecordCount > 0 Then
With Data1.Recordset
client_enr.adresse = getfield(Data1.Recordset, "adresse")
client_enr.article = getfield(Data1.Recordset, "article imposition")
client_enr.client = getfield(Data1.Recordset, "code client")
client_enr.matricule = getfield(Data1.Recordset, "matricule fiscal")
client_enr.nom = getfield(Data1.Recordset, "nom client")
client_enr.registre = getfield(Data1.Recordset, "registre de commerce")
client_enr.telephone = getfield(Data1.Recordset, "telephone")
client_enr.type = getfield(Data1.Recordset, "client type")
client_enr.ville = getfield(Data1.Recordset, "ville")
End With
End If
Screen.MousePointer = vbDefault

End Sub


Private Sub txtFields_KeyPress(Index As Integer, _
KeyAscii As Integer)

If KeyAscii = 13 Then
SendKeys "{tab}", 1
Exit Sub
End If
If Index = 1 Then
KeyAscii = IIf(KeyAscii >= 97 And KeyAscii <= 122, KeyAscii - 32, KeyAscii)
End If

End Sub



vblover
0
otareed Messages postés 4 Date d'inscription vendredi 12 mars 2010 Statut Membre Dernière intervention 29 octobre 2010
28 oct. 2010 à 23:28
je vs remercie pr votre aide ,je pe te donner plus de précision ;moi je ve comprendre seulement le principe de travail ,jai commence de faire une base de donnée sur access contenant (les champs :nom ,prenom age ),jai fé ausi une interface vb sur vb.net 2008 ( textbox pr nom ,text box pr prenom et textbox pr age ,jai ajouter des bottons supprimer ,modifier ,ajouter .....),jai fé la liaison vb access ;mais le code de vb nn,je voudrais savoir le code pour appliquer ce petit projet et merci pour vs mon ami
0
vblover Messages postés 57 Date d'inscription mardi 25 février 2003 Statut Membre Dernière intervention 27 janvier 2011
29 oct. 2010 à 12:49
en vb.net 2005 voici un code qui marche
nb: cmdajouter nom du bouton ajouter
cmdsupprimer nom du bouton supprimer
cmdmaj nom du bouton mettre a jour
cmdmodifier nom du bouton modifier
dtr objet data table row pour contenir l'enregistrement en cour a declarer as public
dtt objet data table qui contient la table objet des modifications ajouts suppressions etc
dts objet dataset qui contient la table ou les tables
Private Sub cmdAjouter_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CmdAjouter.Click
' routine pour ajouter un enregistrement
'creation d'une nouvelle ligne
Dtr_Client = Dts_Client.Tables("clients").NewRow
Tout ce qui commence par Me.Txt est un textbox dans ma form
Me.Txtnom.BackColor = Gcol_ActiveColor
Me.CmdModifier.Enabled = False
Me.CmdSupprimer.Enabled = False
Me.txtcode.Text = ""
Me.Txtnom.Text = ""
Me.Txtadresse.Text = ""
Me.LBox_type.Text = "Public"
Me.Txtville.Text = ""
Me.Txtsolde.Text = "0.00"
Me.Txttelephone.Text = ""
Me.Txtregistre.Text = ""
Me.Txtmatricule.Text = ""
Me.Txtarticle.Text = ""
Me.Txtstatut.Text = "Actif"
'ajout de la ligne dans le DataSet
CmdModifier.Enabled = False
CmdSupprimer.Enabled = False
CmdMaj.Enabled = True
Me.Txtnom.Focus()

End Sub

Private Sub CmdMaj_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CmdMaj.Click
'création et exécution du commandbuilder pour mettre à jour le DataAdapter
' eviter que le champs nom et/ou type client soit vide
If Len(RTrim(LTrim(Me.Txtnom.Text))) = 0 Then
MsgBox("Saississez le nom", MsgBoxStyle.Critical)
Me.Txtnom.Focus()
Exit Sub
End If
cmdb_client = New OleDbCommandBuilder(dta_client)
cmdb_client.QuotePrefix = "["
cmdb_client.QuoteSuffix = "]"
If Gstr_EditMode = "Ajout" Then
Gstr_EditMode = ""
Me.CmdModifier.Enabled = True
Me.CmdSupprimer.Enabled = True
dtr_client = dts_client.Tables("clients").NewRow
'modification des données
dtr_client.BeginEdit()
dtr_client("nom client") = Me.Txtnom.Text
dtr_client("adresse") = Me.Txtadresse.Text
dtr_client("ville") = Me.Txtville.Text
dtr_client("registre de commerce") = Me.Txtregistre.Text
dtr_client("article imposition") = Me.Txtarticle.Text
dtr_client("matricule fiscal") = Me.Txtmatricule.Text
dtr_client("telephone") = Me.Txttelephone.Text
dtr_client("client type") = Me.LBox_type.SelectedItem
dtr_client("efface") IIf(Me.Txtstatut.Text "Efface", vbTrue, vbFalse)
dtr_client("solde") = 0
dtr_client.EndEdit()
'ajout de la ligne dans le DataSet
dts_client.Tables("clients").Rows.Add(dtr_client)
Else
If Gstr_EditMode = "Modif" Then
Gstr_EditMode = ""
'récupération de la ligne sur laquelle on est placés dans le datarow
Dtr_Client = Dts_Client.Tables("clients").Rows(rownum)
End If
End If
'mise à jour des données du dataadapter(dta)à partir du commandbuilder (cmdb)
If Obj_ConnectionFixe.State = ConnectionState.Closed Then
Try
Obj_ConnectionFixe.Open()
Catch ex As Exception
MsgBox("connection impossible")
Exit Sub
End Try
End If
dta_client.Update(dts_client, "clients")
'on vide le dataset pour le recréer avec les nouvelles données

dts_client.Clear()
dta_client.Fill(dts_client, "clients")
dtt_client = dts_client.Tables("clients")
Obj_ConnectionFixe.Close()
If dtt_client.Rows.Count > 0 Then
CmdModifier.Enabled = True
CmdSupprimer.Enabled = True
Else
CmdModifier.Enabled = False
CmdSupprimer.Enabled = False
End If
CmdMaj.Enabled = False
End Sub

Private Sub Cmdmodifier_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CmdModifier.Click
Gstr_EditMode = "Modif"
'récupération de la ligne sur laquelle on est placés dans le datarow
dtr_client = dts_client.Tables("clients").Rows(rownum)

'modification des données
dtr_client("nom client") = Me.Txtnom.Text
dtr_client("adresse") = Me.Txtadresse.Text
dtr_client("ville") = Me.Txtville.Text
dtr_client("registre de commerce") = Me.Txtregistre.Text
dtr_client("article imposition") = Me.Txtarticle.Text
dtr_client("matricule fiscal") = Me.Txtmatricule.Text
dtr_client("telephone") = Me.Txttelephone.Text
dtr_client("client type") = Me.LBox_type.SelectedItem
dtr_client("efface") IIf(Me.Txtstatut.Text "Efface", vbTrue, vbFalse)
CmdMaj.Enabled = True
End Sub

Private Sub cmdsupprimer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CmdSupprimer.Click

Dim bl_efface As Boolean
Gstr_EditMode = "Suppression"
'suppression de la ligne en cours
bl_efface = dtt_client.Rows(rownum).Item("efface")
dtt_client.Rows(rownum).Item("efface") = Not (bl_efface)
If Not (bl_efface) Then
CmdSupprimer.Text = "Restaurer"
Txtnom.BackColor = gcol_inactivecolor
Txtstatut.Text = "Efface"
Else
CmdSupprimer.Text = "&Supprimer"
Txtnom.BackColor = gcol_activecolor
Txtstatut.Text = "Actif"
End If

CmdMaj.Enabled = True
End Sub

Bonne chance



vblover
0
otareed Messages postés 4 Date d'inscription vendredi 12 mars 2010 Statut Membre Dernière intervention 29 octobre 2010
29 oct. 2010 à 20:31
merci bcp mon ami
0
Rejoignez-nous