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

  • Thread starter Thread starter insomniux
  • Start date Start date
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
 
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
 
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
 
Back
Top