Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New Records and Changed Records

Status
Not open for further replies.

hijinx

Programmer
Nov 28, 2001
5
US
I'm trying to distinguish between a New record and a Changed record. I have a Y/N field hidden on my form called "Changed". Whenever a record changes, I want the YN field to be updated to True. I am currently using the form's Dirty property to do this. However, New records are being marked as well as Changed records. Am I using the wrong event?

Thanks for your help!

Hijinx
 
Hi

What I would do is

Have two columns Inserted and Amended

In the before Insert even of the form put Inserted = True

In the BEfore Update Event of the form put Amended = True

Now if Insterted = True record was inserted, if Inserted = False and Amended = True record was amended

Bu I think I would Use Dates (or date/time depending on how exact you want to be), other wise do you not have to have a mechanism to unset the 'flags'

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
I guess you've got something like;

Code:
Private Sub Form_AfterUpdate()
Or a particular fieldbox
Code:
[COLOR=red]Changed.value = True[/color]

End Sub

>Whenever a record changes, I want the YN field to be updated to True. I am currently using the form's Dirty property to do this. However, New records are being marked as well as Changed records. Am I using the wrong event?

Are you using an add new button on the same form you use to edit fields (and set changed=true)?

You could set a variable on load / 'Add new' button click that checks the current record state (i.e new/stored) and use that to condition the update code.
Somthing like

Code:
Private Sub Form_OnLoad()

Dim Var As String

if IsNull(Box1) And IsNull(Box2) then

   Var.value = "New"
else
   Var.value = "Stored"

end if

End Sub

Private Sub Form_AfterUpdate()

if Var.value = "Stored" then

    Changed.value = True

end if

End Sub

Or something like that, but tell me more as Im not sure how your record is 'changed' or how you add a new one.

J

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top