Bruno said:
i'm not understanding very well, but i will send my function and then maybe
you can help me, if you want:
Function primeiroano()
Dim x, y, t
Dim anoa As Long
Dim adaqui As String
Dim dias As String
Dim perc As String
Dim vcomp As String
Set anoa = Form_Inventário.Tanoactual.Value
Set adaqui = Form_Inventário.Tanodataaquisicao.Value
Set dias = Form_Inventário.Tcaixadias.Value
Set perc = Form_Inventário.Tpercentagem.Value
Set vcomp = Form_Inventário.Tvalorcompra.Value
Set t = Form_Inventário.T1ano.Value
If anoa = adaqui Then
x = (dias / 365)
y = (perc * vcomp)
t = x * y
Else
t = "0"
End If
End Function
The name of the fields are in portuguese, os don't worry because of the
names, if ou don't understand. the question is the same i put before. how can
i get the values from the fields and calculate them and set in the T1ano
field (= vairant t)
I'm not understanding very well either.
It appears that you are getting the values from the
**controls** on the form.
There are two problems I can see in the function's code.
One is that you should not be returning a string when anoa
does not equal adaqui. That line should be:
t = 0
The other is that the function never sets its return value.
I think you want the line:
primeiroano = t
before the End Function line.
Once you have the function working properly, you can use it
to display the calculated result in a text box on the form
by using a control source expression like:
=primeiroano()