Hi everyone,
I'm a new one. I got a problem with a forms in access + vba. It doesn't work and I can't find out what's wrong with it. Please help if you have a better idea. Many thanks.
Well, I created a forms "Fclient" for searching, adding,.. a record into a table named "Tclient".
In this table " Tclient " i have
ncli int Auto_increment, Primary key
nom Text, nomindex
prenom Text
adresse Text
tel Text
supression yes/no
remarque: I used Access 2000 so .."Option Explicit" is demanded
nomi, teli, prenomi, adressei...are the name of the Input Ab have used in forms "Fclient"
In the Forms "Fclient", in VBA code I wrote :
I'm a new one. I got a problem with a forms in access + vba. It doesn't work and I can't find out what's wrong with it. Please help if you have a better idea. Many thanks.
Well, I created a forms "Fclient" for searching, adding,.. a record into a table named "Tclient".
In this table " Tclient " i have
ncli int Auto_increment, Primary key
nom Text, nomindex
prenom Text
adresse Text
tel Text
supression yes/no
remarque: I used Access 2000 so .."Option Explicit" is demanded
nomi, teli, prenomi, adressei...are the name of the Input Ab have used in forms "Fclient"
In the Forms "Fclient", in VBA code I wrote :
Code:
Option Compare Database
Option Explicit
Dim mabase As Database
Dim tcli As Recordset
Private Sub bajoute_Click()//add a record into a table 'Tclient'
Set mabase = CurrentDb
Set tcli = mabase.OpenRecordset("Tclient", dbOpenTable)
tcli.AddNew
tcli![nom] = Forms!Fclient!nomi
tcli![prenom] = Forms!Fclient!prenomi
tcli![adresse] = Forms!Fclient!adressei
tcli![tel] = Forms!Fclient!teli
ncli = tcli![nclient]
tcli.Update
End Sub
Private Sub befface_Click() //Erase input data
Forms!Fclient!nomi = ""
Forms!Fclient!prenomi = ""
Forms!Fclient!adressei = ""
Forms!Fclient!teli = ""
Forms!Fclient!ncli = ""
Forms!Fclient![nomi].SetFocus
End Sub
Private Sub brecher_Click()//search a record in table "Tclient"
Set mabase = CurrentDb
Set tcli = mabase.OpenRecordset("Tclient", dbOpenTable)
tcli.Index = "nomclientindex"
tcli.Seek "=", Forms!Fclient!nomi
If tcli.NoMatch = False Then
If tcli![supression] = False Then
Forms!Fclient!nomi = tcli![nom]
Forms!Fclient!prenomi = tcli![prenom]
Forms!Fclient!adressei = tcli![adresse]
Forms!Fclient!teli = tcli![tel]
Forms!Fclient!ncli = tcli![nclient]
Else
MsgBox "ce client n'existe plus"
Forms!Fclient!nomi = ""
Forms!Fclient![nomi].SetFocus
End If
Else
MsgBox "ce client n'existe pas"
Forms!Fclient!nomi = ""
Forms!Fclient![nomi].SetFocus
End Sub
Last edited by a moderator: