D
diaa
Guest
Hi All,
I need use find Method with string field but I can't. error when I start compilation.
but when I put a integer field work fine.
the code source is:
Function Compare(Code, Qte As Integer) As Boolean
(if Code string don't work)
Dim RS As DAO.Recordset
Dim DB As DAO.Database
Set DB = Application.CurrentDb
Set RS = DB.OpenRecordset("Produits", dbOpenDynaset)
Dim cuml As Integer
RS.FindFirst "Réfproduit=" & CStr(Code) (ERROR)
cuml = 0
Do While (RS.NoMatch <> True) And (Not RS.EOF)
cuml = cuml + RS.Fields("Quantité Acheté").Value
RS.FindNext "Réfproduit=" & CStr(Code)
Loop
If Qte < cuml Then
Compare = True
Else
Compare = False
End If
RS.Close
Set RS = Nothing
Set DB = Nothing
End Function
Thanks in advance
I need use find Method with string field but I can't. error when I start compilation.
but when I put a integer field work fine.
the code source is:
Function Compare(Code, Qte As Integer) As Boolean
(if Code string don't work)
Dim RS As DAO.Recordset
Dim DB As DAO.Database
Set DB = Application.CurrentDb
Set RS = DB.OpenRecordset("Produits", dbOpenDynaset)
Dim cuml As Integer
RS.FindFirst "Réfproduit=" & CStr(Code) (ERROR)
cuml = 0
Do While (RS.NoMatch <> True) And (Not RS.EOF)
cuml = cuml + RS.Fields("Quantité Acheté").Value
RS.FindNext "Réfproduit=" & CStr(Code)
Loop
If Qte < cuml Then
Compare = True
Else
Compare = False
End If
RS.Close
Set RS = Nothing
Set DB = Nothing
End Function
Thanks in advance