Object required "ERROR"

G

Guest

Hi,
i have this function showed:
Private Sub T1ano_Enter()
Dim x, y, t
Dim anoa As Long
Dim adaqui As Long
Dim dias As Long
Dim perc As Long
Dim vcomp As Long

Set anoa = Me.Tanoactual.Value
Set adaqui = Me.Tanodataaquisicao.Value
Set dias = Me.Tcaixadias.Value
Set perc = Me.Tpercentagem.Value
Set vcomp = Me.Tvalorcompra.Value
Set t = Me.T1ano

'If anoa = adaqui Then
' x = (dias / 365)
' y = (perc * vcomp)
' t = x * y
'Else
' t = "0"
'End If

End Sub

when i'm start to ru nalways show this error message "Object required error"
and open VBA and put the cursor in the set variable!
thanks for any help.
 
G

Guest

Hey Bruno, the "Set" statement is used to assign an object reference to a
variable or property. To assign a value to your variables, remove the Set
statements, like this:

anoa = Me.Tanoactual.Value
adaqui = Me.Tanodataaquisicao.Value
dias = Me.Tcaixadias.Value
perc = Me.Tpercentagem.Value
vcomp = Me.Tvalorcompra.Value
t = Me.T1ano
 
M

Marshall Barton

Bruno said:
Hi,
i have this function showed:
Private Sub T1ano_Enter()
Dim x, y, t
Dim anoa As Long
Dim adaqui As Long
Dim dias As Long
Dim perc As Long
Dim vcomp As Long

Set anoa = Me.Tanoactual.Value
Set adaqui = Me.Tanodataaquisicao.Value
Set dias = Me.Tcaixadias.Value
Set perc = Me.Tpercentagem.Value
Set vcomp = Me.Tvalorcompra.Value
Set t = Me.T1ano

'If anoa = adaqui Then
' x = (dias / 365)
' y = (perc * vcomp)
' t = x * y
'Else
' t = "0"
'End If

End Sub

when i'm start to ru nalways show this error message "Object required error"
and open VBA and put the cursor in the set variable!


Sorry I didn't notice that problem in your other thread
about this function.

The Set statement is only used when assigning an object to
an object variable. You should not use it to assign simple
values so just remove the Set from each line.

Please maintain a single thread for a question. It's very
confusing to have to jump back and forth between multiple
threads to figure out what the problem is and what progress
has been made.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top