ctl.OldValue Why Oh Why won't you work? 
Author Message
 ctl.OldValue Why Oh Why won't you work?

My app needs to track changes to certain records and write info about
those changes to a table.

So I set a module level boolean variable in the proc that opens the form
for editing.  In the Form_BeforeUpdate proc, if the boolean is true, I
record the necessary info about the change.  The problem is that for one
field the OldValue property doesn't work - it generates Error 438
(Object doesn't support this property or method).   This is the same
error generated if you try to check OldValue for a label, for instance.
 It is only on this one field, all the others work fine.

So, Things I have already tried.

1.  Make sure that the focus is set to a diffent control than the one in
question (I unhide a control that is never seen by the user - and never
changed when editing the record, and set the focus to that control.)  
Doesn't make a difference.

2. Thinking that the form may be corrupt, I recreated it by copying all
controls and all code into a new form.  (General remedy I learned once
on an old machine with a full hard drive. Didn't make a difference in
this case.)

3.  The control in question has a "default" value supplied by code when
the user is initially creating the record.  Thinking that this may mess
with the OldValue property, I disabled the code.  It didn't make any
difference.

4.  I visually compared all the properties of the text box in question
with the properties of another textbox on the form.  There are no
significant differences.  (Differences are things like TabOrder, Top,
ControlSource, etc. )

As you can see, I am casting about in the dark.  I am also getting
desperate - this feature is a high priority for my users.  Can anyone
offer any insight here?  Please respond by mail as well as in the
newsgroup.

Muchas, MUCHAS gracias!

Gordon Young



Tue, 28 Mar 2000 03:00:00 GMT  
 ctl.OldValue Why Oh Why won't you work?


Quote:
> So I set a module level boolean variable in the proc that opens the form
> for editing.  In the Form_BeforeUpdate proc, if the boolean is true, I
> record the necessary info about the change.  The problem is that for one
> field the OldValue property doesn't work - it generates Error 438
> (Object doesn't support this property or method).   This is the same
> error generated if you try to check OldValue for a label, for instance.
>  It is only on this one field, all the others work fine.

You can't check OldValue for UNBOUND controls -- perhaps that's your
problem? -- Ken


Thu, 30 Mar 2000 03:00:00 GMT  
 ctl.OldValue Why Oh Why won't you work?

Is your form based on a query with joined tabels? I was trying to something
simmilar and got the same error message.

Mocrosoft support explained the problem as follows:

"The problem is the way that the query that the form is based on is being
updated. This behavior is by design.

The relationship between the tables in the query (the joining of the
primary key in the first table to the foreign key in the second table) is
causing the problem whenever a field in the second table is updated. This
updating causes the fields in the first table to be "required" whenever a
value in the second table is changed. At that point, the OldValue property
of the controls bound to fields in the first table is no longer valid."

The explanation was longer but since I don't know if you are using a query
like this, I will stop there for now. Mail me if you want the rest.

Hope this helps
Lars Fransn


Quote:
> My app needs to track changes to certain records and write info about
> those changes to a table.

> So I set a module level boolean variable in the proc that opens the form
> for editing.  In the Form_BeforeUpdate proc, if the boolean is true, I
> record the necessary info about the change.  The problem is that for one
> field the OldValue property doesn't work - it generates Error 438
> (Object doesn't support this property or method).   This is the same
> error generated if you try to check OldValue for a label, for instance.
>  It is only on this one field, all the others work fine.

> So, Things I have already tried.

> 1.  Make sure that the focus is set to a diffent control than the one in
> question (I unhide a control that is never seen by the user - and never
> changed when editing the record, and set the focus to that control.)  
> Doesn't make a difference.

> 2. Thinking that the form may be corrupt, I recreated it by copying all
> controls and all code into a new form.  (General remedy I learned once
> on an old machine with a full hard drive. Didn't make a difference in
> this case.)

> 3.  The control in question has a "default" value supplied by code when
> the user is initially creating the record.  Thinking that this may mess
> with the OldValue property, I disabled the code.  It didn't make any
> difference.

> 4.  I visually compared all the properties of the text box in question
> with the properties of another textbox on the form.  There are no
> significant differences.  (Differences are things like TabOrder, Top,
> ControlSource, etc. )

> As you can see, I am casting about in the dark.  I am also getting
> desperate - this feature is a high priority for my users.  Can anyone
> offer any insight here?  Please respond by mail as well as in the
> newsgroup.

> Muchas, MUCHAS gracias!

> Gordon Young



Thu, 30 Mar 2000 03:00:00 GMT  
 ctl.OldValue Why Oh Why won't you work?

Quote:

> Is your form based on a query with joined tabels? I was trying to something
> simmilar and got the same error message.

No, Actually, the form is based directly on the table.  But thanks for
the info/Warning.  I can well imagine myself tripping over this one
under other circumstances.
Quote:
> Mocrosoft support explained the problem as follows:

> "The problem is the way that the query that the form is based on is being
> updated. This behavior is by design.

> The relationship between the tables in the query (the joining of the
> primary key in the first table to the foreign key in the second table) is
> causing the problem whenever a field in the second table is updated. This
> updating causes the fields in the first table to be "required" whenever a
> value in the second table is changed. At that point, the OldValue property
> of the controls bound to fields in the first table is no longer valid."



Fri, 31 Mar 2000 03:00:00 GMT  
 ctl.OldValue Why Oh Why won't you work?

Quote:
> >  It is only on this one field, all the others work fine.

> You can't check OldValue for UNBOUND controls -- perhaps that's your
> problem? -- Ken

If only it were so simple!  In fact it is a bound control (Under the
circumstances, if it weren't bound, I would care about the old value.)  

But Thank you anyway.

G.



Fri, 31 Mar 2000 03:00:00 GMT  
 ctl.OldValue Why Oh Why won't you work?

The revised code works because you are only trying to use OldValue for
controls which support it. If you try to use OldValue of all controls, it
will fail for labels and other controls which don't support it.

ray

Quote:

>Well, I found something that works (in limited testing so far), but I still
don't
>understand it at all.  If I test for the type of Control, I can read the
OldValue
>property, but otherwise I can't.  Anyone got any ideas as to why?  I have
included two
>listings below; the code in each is the same except that different lines
are commented
>out.

>'''''''''''''''''''''''''''''
>' Works:
>'''''''''''''''''''''''''''''

>         Application.Echo False
>         With Me!txtBitmID
>            .ColumnHidden = False
>            .SetFocus
>         End With

>     ' On Error Resume Next
>         For Each ctl In Me.Controls
>            If (TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox) Then
>               If ctl <> ctl.OldValue Then
>             ' If Err <> 0 Then Debug.Print ctl.Name, Err, Err.Description
>             ' If Err <> 438 Then
>                  strOldVs = strOldVs & "," & ctl.OldValue
>                  strNewVs = strNewVs & "," & ctl
>                  strFields = strFields & "," & ctl.Name 'Mid(ctl.Name, 4)
>               End If
>            End If
>         Next ctl

>         Me!txtBitmAmount.SetFocus
>         Me!txtBitmID.ColumnHidden = True
>         Application.Echo True

>     ' On Error GoTo LineError

>'''''''''''''''''''''''''''''
>' Doesn't Work:
>'''''''''''''''''''''''''''''

>         Application.Echo False
>         With Me!txtBitmID
>            .ColumnHidden = False
>            .SetFocus
>         End With

>      On Error Resume Next
>         For Each ctl In Me.Controls
>          ' If (TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox) Then
>            If ctl <> ctl.OldValue Then
>               If Err <> 0 Then Debug.Print ctl.Name, Err, Err.Description
>               If Err <> 438 Then
>                  strOldVs = strOldVs & "," & ctl.OldValue
>                  strNewVs = strNewVs & "," & ctl
>                  strFields = strFields & "," & ctl.Name 'Mid(ctl.Name, 4)
>               End If
>            End If
>         Next ctl

>         Me!txtBitmID.ColumnHidden = True
>         Me!txtBitmAmount.SetFocus
>         Application.Echo True

>      On Error GoTo LineError



Sat, 01 Apr 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Why oh why doesn't this work?

2. VB6 ListView: Why oh why oh why...

3. VB6 ListView: Why oh why oh why...

4. Two Q's [Closing a file][why won't work]

5. ActiveX wont deploy to Win 2K - why, Why WHY

6. Why -- Oh Why !!!!!!!!

7. DELPHI - why oh why Pascal?

8. Why won't this work?

9. Why won't this work?

10. Q: Why won't this work

11. Why won't INSTR() work!!???

12. Why won't AllowZeroLength work?

 

 
Powered by phpBB® Forum Software