VBA ACCESS problème de collection
VBA_boy
-
VBA_boy -
VBA_boy -
Bonjour,
Je travail sous Access pour faire un projet de gestion de devis et j'ai un problème avec une portion de mon code je vous le soumet :
Code :
Cette partie c'es ma classe client :
Public Nom As String
Public Prenom As String
Public Id As String
Public Function AddVendor(ByVal sid As Integer, ByVal sNom As String, ByVal sPrenom As String)
Id = sid
Nom = sNom
Prenom = sPrenom
End Function
Cette partie c'est le code principal :
Private oColl As New Collection
Private Sub Form_Load()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim sSQL As String
Dim i As Integer
i = 0
' Ouverture de la base de données
Set db = CurrentDb
sSQL = "Select ID_CLT, NOM_CLT, PRE_CLT FROM CLIENT"
Set rst = db.OpenRecordset(sSQL, dbOpenForwardOnly, dbReadOnly)
While Not rst.EOF
addCLT rst.Fields(0), rst.Fields(1), rst.Fields(2)
rst.MoveNext
Wend
Me!Liste0.ColumnCount = 2
Me!Liste0.ColumnWidths = "1000;1000"
Me!Liste0.RowSource = "Nom;Prénom"
'Parcour du recordset
For i = 1 To 5
<gras>Set oreqven = oColl(i)
MsgBox oreqven.Id '& vbCrLf & oColl(i).Nom & vbCrLf & oColl(i).Prenom
Next i
rst.Close
End Sub
Private Sub addCLT(Id As String, Nom As String, Prenom As String)
Dim oClient As Client
Set oClient = New Client
oClient.AddVendor Id, Nom, Prenom
oColl.Add oVendor, oClient.Id
End Sub
</gras>
Il me donne une erreur : "Incomptabilité de type" en me sulignatn la ligne en gras.
Merci de me donné un eu d'aide je ne m'en sort plus.
Je travail sous Access pour faire un projet de gestion de devis et j'ai un problème avec une portion de mon code je vous le soumet :
Code :
Cette partie c'es ma classe client :
Public Nom As String
Public Prenom As String
Public Id As String
Public Function AddVendor(ByVal sid As Integer, ByVal sNom As String, ByVal sPrenom As String)
Id = sid
Nom = sNom
Prenom = sPrenom
End Function
Cette partie c'est le code principal :
Private oColl As New Collection
Private Sub Form_Load()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim sSQL As String
Dim i As Integer
i = 0
' Ouverture de la base de données
Set db = CurrentDb
sSQL = "Select ID_CLT, NOM_CLT, PRE_CLT FROM CLIENT"
Set rst = db.OpenRecordset(sSQL, dbOpenForwardOnly, dbReadOnly)
While Not rst.EOF
addCLT rst.Fields(0), rst.Fields(1), rst.Fields(2)
rst.MoveNext
Wend
Me!Liste0.ColumnCount = 2
Me!Liste0.ColumnWidths = "1000;1000"
Me!Liste0.RowSource = "Nom;Prénom"
'Parcour du recordset
For i = 1 To 5
<gras>Set oreqven = oColl(i)
MsgBox oreqven.Id '& vbCrLf & oColl(i).Nom & vbCrLf & oColl(i).Prenom
Next i
rst.Close
End Sub
Private Sub addCLT(Id As String, Nom As String, Prenom As String)
Dim oClient As Client
Set oClient = New Client
oClient.AddVendor Id, Nom, Prenom
oColl.Add oVendor, oClient.Id
End Sub
</gras>
Il me donne une erreur : "Incomptabilité de type" en me sulignatn la ligne en gras.
Merci de me donné un eu d'aide je ne m'en sort plus.
A voir également:
- VBA ACCESS problème de collection
- Exemple base de données access à télécharger gratuit - Forum Access
- Acer quick access - Forum logiciel systeme
- Désinstaller ACER QUICK ACCESS - Forum Logiciels
- Access appdata - Guide
- Exemple base de données Access de gestion ✓ - Forum Logiciels