Re: how to get both old and new value for a changed text box



Something else you might think about Kathy,

I usually read data directly into controls like textbox's using a data
reader. I did work on a project in my early days of .NET where we used
a Currency Manager and the controls were bound too the DataTable. In
this set up, before the Table.AcceptChanges() method is called the
table actually contains the original value and proposed value.

This way there would be no reason to check every control individually.

Do some reading in the BOL about DataTables and Currency Managers.

Additionally, you mentioned Sql Server, if this is the database your
using then I would put an Update Trigger on the table and when it
fires, insert the old record into an identical table.

On another note.....

Sorry about the sarcastic feedback you got, in our line of work their
seems to be a lot if idiots with god syndrome.

Izzy


Kathy wrote:
Brian,

I have set this up to work with either a MS Access or SQL Server
database. I think I've accomplished both issues now. Inside the LEAVE
event I'm comparing the old to the new value as suggested by Jim.
Inside the ENTER event I was storing the value in a global variable.
But I like your idea of using the Tag property for saving the old value
better than what I did. That way I can compare all the text boxes
during the binding source's CurrentChanged event. Does that sound
reasonable?

Thanks !
Kathy

Brian Tkatch wrote:
There are two basic issues you are trying to address.

1) If it changed.
2) The old value.

Before looking into a VB answer to this, if this is being ported from
Access, you may now be using an actual database. In which case, you can
add a TRIGGER to be fired ON UPDATE, and capture the change at the
database level.

If the answer is to come from VB, a simple answer would be set the Tag
property to the old value as soon as the data is loaded. Then, when
storing the new data, compare it with the stored old value.

For mutiple textboxes, a loop could be employed. For example, to store
the data:

For Each Current_Control As Control In Me.Controls
If Current_Control.GetType Is GetType(TextBox) Then
Current_Control.Tag = Current_Control.Text
Next

HTH,
B.

.



Relevant Pages

  • Re: The Zen nature of a Delphi database application
    ... results directly to UI controls, then write data from the controls to ... then write data back from the modified objects to the DB for storage? ... I load the whole contents of the database into my business objects, ... I have dreamt of the perfect OO database application framework ...
    (comp.lang.pascal.delphi.misc)
  • Re: multiple subform images per main search form record
    ... Document ScreenDumps of: ... get a marker and label all controls with the Name property so when you ... save your word doc in the directory with the database you are documenting ... Show Images from Continuous Subform ...
    (microsoft.public.access.formscoding)
  • Re: When to (not) use the ADO data control
    ... > over is that you should use unbound controls in favor of bound controls. ... simple database program for your own use, ... > programmer that wrote the application used a mixture of DAO data controls ... I am by no means an advocate of bound controls. ...
    (microsoft.public.vb.general.discussion)
  • Re: Setting a referenced object to null
    ... "The controls" is an extremely non-specific description. ... of data that is fetched from a database. ... the variable reference something else. ... need to filter what is seen and what is not seen. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: ADD method syntax for collections
    ... any database record was capable of displaying three photographs; ... I get "Photo4" highlighted in a line "If ... or is it a query? ... On that form, I guess you have controls that are, or are supposed to be, bound to the Photo fields. ...
    (microsoft.public.access.formscoding)

Loading