Field Property (OldValue) not available in Field Object defined withDim As Field?

I

insomniux

Hi,

Here some code (in BeforeUpdate event in a form):
Dim MyField as Field
Set MyField = Me.TestField 'This is the name of a field on my form
If MyField.OldValue > 100 Then ....

MsAccess (2000) complains that the property .OldValue cannot be found

However when I use the code
If Me.TestField.OldValue > 100 Then ....
There is no complaining.

Is this a bug? How can it be solved?
Thanks
Mike
 
D

Dirk Goldgar

insomniux said:
Hi,

Here some code (in BeforeUpdate event in a form):
Dim MyField as Field
Set MyField = Me.TestField 'This is the name of a field on my form
If MyField.OldValue > 100 Then ....

MsAccess (2000) complains that the property .OldValue cannot be found

However when I use the code
If Me.TestField.OldValue > 100 Then ....
There is no complaining.

Is this a bug? How can it be solved?


Me.TestField is not a Field object; it's a Control object. The OldValue
property applies only to Control objects, and not to all of those. With
"Dim MyField As Field", you are probably declaring MyField as either a DAO
Field object or and ADODB Field object, and those do not have an OldValue
property. Declare MyField like this instead:

Dim MyField As Control
 
I

insomniux

Me.TestField is not a Field object;  it's a Control object.  The OldValue
property applies only to Control objects, and not to all of those.  With
"Dim MyField As Field", you are probably declaring MyField as either a DAO
Field object or and ADODB Field object, and those do not have an OldValue
property.  Declare MyField like this instead:

    Dim MyField As Control

Thanks Dirk,
Of course you're right. I obviously got confused by the naming of the
objects/controls.
Mike
 

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